, rails builds the relevant presentation layer, control layer, and data layer code for us. Specific grammatical details, I will study after, now do not care.We can open the App/views/memos folder to see the specific code generated.(4) Establishing a databaseEnter the following command in the terminal to establish the database:Rake Db:migrateSqlLite3 automatically creates a database based on the data model.(
website performance. By default, Rails stores the cache in a file system, which is not a suitable storage method in the production environment and has limited file I/O efficiency, rails also supports saving Cache in the memory of the same process. However, if multiple Rails Applications exist, they cannot share the Cache. We recommend using MemCached for storage
the line to the following code:
[3] app/views/memos/index.html. ERB file, Row 3
Change the line to the following code:
[4] app/views/memos/index.html. ERB file: 27th rows
Change the line to the following code:
2.6 modify the config/application. RB File
Cancel the comments of row 20th and line 21st, change 'my to 'config', change de to: ZH, and add a line of code config. encoding = 'utf-8'. The Code is a
/view/controller (model/view/controller, MVC) architecture. Although this technology is not unique to Rails-or even not unique to Web applications (compared to other programs), Rails has a very clear and specific MVC way of thinking. If you do not use the MVC method, Rails will be much less useful (compared to following its pattern ).Model
The model of the
conditions, loops, and other logic as part of an enhanced HTML tag.
Generate code
The tools provided by Rails are primarily a set of code generators. I prefer this approach to the development environment that forces me to use a rigorous workspace and IDE. Rails won't get in the way of you, but it will save you most of your hand-programmed work-or, by providing a "free" preliminary (First-pass) bracket (s
Internet upstarts, including Twitter, Groupon and Hulu.
Quickly create a Rails 3 application
To step through the functionality features of Rails 3, here is an incremental model for developing a simple blog model. After RAILS3 is installed, run the command: Rails new Demoblog.
Demoblog the types of files required by the application are automatically generated.
can go into the Rails services container and execute the commands we need. Enter the container for the Rails service:
Docker-compose EXEC Rails BashHello,rails
Let Rails say "hello" and you can create a simple controller and view.
Using the controller manufacturer, creat
This paper analyzes the MVC architecture of Rails 3 and discusses the methods and techniques of data transfer between the controller and view of Rails 3, controller and model, view and layout, and multiple views. Assuming you have a basic understanding of Ruby on Rails, you can at least configure Ruby on
use diagnostic tools that provide you with a repeatable and accurate volume.
Detect performance problems
One of the best tools is the Rails development log, which is usually located in the log/development. log file on each development machine. It has a variety of comprehensive indicators: the total time spent in responding to requests, the percentage of time spent in the database, and the percentage of time spent in generating
scope. It originated from smalltalk. Today, almost all gui frameworks, including web and fat clients, are based on this framework. MVC has three parts:Model, Responsible for the business logic, including the application status and the actions that will be executed in this status;ViewUsed to render and present models to users (in Web applications, views are generally rendered as HTML );ControllerDefines the behavior of an application. For more informa
The previous 30 articles are based on the contents of the book written, rarely have their own understanding, from this beginning to understand some of the internal rails mechanism, so understand more things, less code, this time we look at the Rails directory structure.
About the directory structure of rails, we should have some understanding of the previous exe
stacks
As you can see, the basic difference between the rails stack and components that constitute common J2EE-based Web applications is very small. Both of them are used to execute application code containers. They both help to separate the application model, view, and control MVC framework, as well as the persistent data storage mechanism.
MVC FrameworkModel-View-controller (MVC) is a design mode with a long application time
Brief introduction
Today's applications need to interoperate not only with browser-based clients, but with other applications as well. For interoperability, Web applications typically provide a Web service API. The Web services API provides remote access to applications through a network, such as the Internet. Until recently, the Web services API had also been integrated with heavy, complex, SOAP-based Web services, which had little merit and would take a long time to implement. The
When pry is used, you will feel that the previously used debugger method is so complicated and troublesome that it brings up the troubles of rails S and takes time to enhance IRB's functions,
By default, the pry configuration is enough, so that the rails console can also rest.
Installation:
Add in gemfile
gem ‘pry‘, :group =gt; :development
Then execute
bundle install
You can.Usage:
Replace the IRB method w
creator:belongs_to
Rake Db:migrate
Modify APP/CONTROLLERS/POSTS_CONTROLLER.RB, log in for operations other than view, and record the identity of the publisher when Post is published:
before_action:authenticate_user!, except: [: Index,: show]
def create
#
... @post = post.new (
title:upload_ret[' title '),
filename:upload_ret[' fname ',
qiniu_hash:upload_ret[' Hash '],
creator:current_user
)
#
... End
Modify APP/MODELS/POST.RB to add a subordinate association
customer switches to a State. With different HTTP commands, rest customers can create, read, update, or delete resource records.
For example, a typical blog is used as an example. Enter a URL, such as blog.rapidred.com, to obtain the list of posts. Then, if you want to edit a blog entry, you can enter an HTTP parameter in the URL (for example, blog.rapidred.com/edit? Article = 12345), and then the edit form is displayed. Because each blog entry has its own URL, you can click the link or directl
Data transmission between views and some views (Partial views), viewpartial
When writing ASP. net mvc programs, we often need to pass data from views to some views (Partial views) or vice versa.Use Insus. NET todayControllerBase.
to the project directory under the command line
Rails has a problem. Even if a Gem cannot be installed, it cannot be run. You can ignore it, when that function is used, an error is prompted (Visual Studio is much simpler and more convenient to publish)
This release service took one or two hours, and it was really difficult :)
Bundle install
Run: rails server # Start the service
Webrick introduction:
Ruby
'Go ':
Create table 'People '('Id' int (10) unsigned not null auto_increment,'Name' varchar (50) not null default '','Street1' varchar (70) not null default '','Street2' varchar (70) not null default '','City' varchar (70) not null default '','State' char (2) not null default '','Zip 'varchar (10) not null default '',Primary key ('id '),KEY 'name' ('name ')) TYPE = MyISAM AUTO_INCREMENT = 2;
Now, click on the SQL tab one more time, and run this query:
Insert into 'others' VALUES (1, 'Superman',
seen installed, such as openSUSE
Copy Code code as follows:
sudo zypper install Sqlite3
Rails 4 Hello,world
Can be generated directly with rails
Copy Code code as follows:
$rails New Hello
And then there's the
Copy Code code as follows:
Create
Create Readme.rdoc
Create Rakefile
Create config.ru
Create. G
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.