Rails 4 can be used to support the postgres of the UUID (universally unique Identifier, the unique identifier) type in the original ecosystem. Here, I'll describe how you can use it to generate a UUID without manually modifying any rails code.
First, you need to activate the postgres extension ' UUID-OSSP ':
Class Createuuidpsqlextension
You can re
First, the new projectRails new App--skip-bundleModify Gemfile file after completion: Vim GemfileChange source to Taobao or Ruby-china.Add to this file: Gem ' Phantomjs 'Then run: Bundle installSo the project is new and completed.Second, generate PDFCreate a controller to add require ' PHANTOMJS ' to the head and add a get method for getting the PDF: get_pdfAdd the following code to this method:Phantomjs.base_dir = "/path/project_name/bin/phantomjs/"
So the implementation of our shopping cart is complete, and we can use Ruby's rdoc to generate documentation for our programs, like Dotnet,java,python, RDoc can extract the annotations from the class and method declarations in our code to generate documents.
For our depot program, we run the Rake appdoc command at the Rails command line, as shown in the figure:
The following issues have been encountered recently in a ROR Web project:
Products can be classified by class navigation browsing, can be divided into three types of a,b,c, three categories under the other categories, at the same time, the base class and its classification can be extended by the user. Horizontally, the main class can be extended by the user, and the user can extend it vertically.
Category information Store and Categories table:
Id:integer PRIMARY Key
Name:string category Nam
application is now complete. No code at all! The development efficiency of the rails framework is fully demonstrated.PostScriptBecause it was the first rails program, we didn't need to delve into Ruby's syntax details on rails, and we used the build tool provided by rails to quickly
plugin directory to: config/ultrasphinx/ Default.base, open this file, will be one of the following:
Charset_type = Utf-8 to: Charset_type = Zh_cn.utf-8 to support full-text retrieval of Chinese characters, and add a line below the Charset_type setting:
Charset_dictpath =/home/test/search/lib, this is the path where the Uni.lib dictionary is mentioned above, and then delete all charset_table related settings.
In the Rails application Model code, a
title and body, and I want to perform full-text search on these two attributes, I can add a row in article. rb:Listing 18. Using ultrasphloud
Is_indexed: fields => ['created _ at', 'title', 'body']
After completing this configuration, we can use the rake ultrasphinx: configure command to generate the Sphinx configuration file. This command creates a development under config/ultrasphment. conf, which is the configuration file of Sphinx. Use the rake u
page of Webpack Dev Server
/webpack/scripts
Files for Rails or Webpack Dev Server environments only
/webpack/server.js
Server.js is the code part of Webpack Dev Server
/webpack/webpack.hot.config.js
Webpack webpack Dev Server configuration file
/webpack/webpack.rails.config.js
Webpack used to generate
, table, style form, and so on-not related to the Controller code.View
The Rails view is where we write Ruby code. Rails contains a very good template language for. rhtml, which combines pure HTML with embedded Ruby code. The most superficial appearance of the Rails application interface is usually controlled by the CSS style form .. Rhtml is an enhanced HTML for
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
sequence usually has a small amount of SQL code, if any. The second part is the view, which contains the code needed to create the output sent to the user, which is usually composed of HTML, JavaScript, and so on. The last part is the controller, which transforms the input from the user into the correct model, and then renders the response with the appropriate view.
Rails advocates are often happy to attribute their ease of use to the MVC paradigm-a
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 views. In addition, som
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
Scaffolding Build command: Rails Generate scaffold Article title:string keywords:string content:text
This generates a article controller, a article view file, and a article model containing the title, keyword, and content three attributes. Run the Database Migration command to generate the related data table: Rake db:migrate. At this point, a simple but complet
, and immediately generate a user interface for the model.
Conventions are better than configurations: to maintain good flexibility, the Java framework maintains a large number of common configuration files. Rails does not use this strategy. It uses a common project directory structure and simple generic naming conventions for methods, classes, tables, and columns to infer which are configured in the Java
$rorails/demoblog/config/database.yml, run the command to create the database: Rake db:create.Now that the simple Demoblog is created, run the server startup command: Rails server.Open http://localhost:3000 to see the typical Welcome page for Rails 3, as shown in 1.Figure 1. Typical Welcome page for Rails 3Rails Scaffolding can quickly build models, views, and c
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
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
. Bundler handles "an application's dependencies across multiple machines throughout its lifecycle," and "only Rails 3 is supported." ”$ CD test_app$ Bundle installUsing Nano to modify the database configuration file, add the password in the development database configuration: "Apple". By convention and the settings in box 1.1, the database name and database user are set.$ nano config/database.ymlNow generate
'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',
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.