[Ror] Ruby on Rails command Learning

Source: Internet
Author: User
Tags ruby on rails

1.1 link_to

General format:

Link_to "XXXX", {hash}, {hash}
The first is the link text, the second hash is the same as url_for, and the third hash is the tag added by the user in <A>, for example:

<% = Link_to " Issues " , {: Controller =>   " Issue " ,: Action =>   " Index " },{: Title =>   " Issues " } %>

Link_to_unless_current automatically identifies the current link. If the current URL is the same as the link, only text is generated.

 

In fact, attributes of HTML elements can be set in this way. For example, add a click event processing:

<% = Link_to " Issues " , {: Controller =>   " Issue " ,: Action =>   " Index " }, {: Onclick =>   " Alert (1) " } %>  

Note: The second parameter of link_to must be given in MAP format. Link_to is the default tool method provided by rails. It also has an overload method: code highlighting produced by actipro codehighlighter (freeware)
http://www.CodeHighlighter.com/
--> <% = link_to " Issues " , " index " ,{: onclick => " alert (1) " } %>

Result: "/XXXXX/controller/index? Onclick = alert (1 )"

 

Therefore, if the second parameter is given in the form of a string, the subsequent parameter becomes querystring.

So how to implement and add Click Event Processing and URL parameters is very simple, as follows:

<% = Link_to " Issues " , {: Controller =>   " Issue " ,: Action =>   " Index " ,: Param = Value},: onclick =>   " Alert (1) "   %>

 

Result:

< A Href = "/Issue/index? Param = value" Script_onclick = "Alert (1 )" > Issues </ A >

1.2 rake
Rake DB: fixtures: Load
# Load fixtures to the database in the current environment
# Load the specified fixtures using fixtures = x, y
Rake DB: migrate
# Migrate the database through the script in the DB/migrate directory. You can specify the version number through version = x
Rake DB: Schema: Dump
# Create a DB/Schema. RB file and use AR to support any database.
Rake DB: Schema: Load
# Re-enter a schema. RB file into the database
Rake DB: Sessions: Clear
# Clearing the sessions table
Rake DB: Sessions: Create
# Use CGI: Session: activerecordstore to create a sessions table for the user
Rake DB: Structure: Dump
# Export the database structure as an SQL File
Rake DB: Test: Clone
# Recreate a test database from the current environment database
Rake DB: Test: clone_structure
# Recreate the test database from the Development Mode Database
Rake DB: Test: Prepare
# Prepare the test database and import the schema
Rake DB: Test: purge
# Clearing the Test Database
Rake DOC: app
# Create an HTML file API documentation
Rake DOC: clobber_app
# Delete documentation
Rake DOC: clobber_plugins
# Delete plugin documentation
Rake DOC: clobber_rails
# Delete documentation
Rake DOC: plugins
# Generate deployment for all installed plugins
Rake DOC: rails
# Create an HTML file API documentation
Rake DOC: reapp
# Force re-create the HTML file API documentation
Rake DOC: rerails
# Force re-create the HTML file API documentation
Rake log: Clear
# Clear all log files in the directory log/
Rake rails: Freeze: edge
# Lock this application to latest edge rails. Lock a specific revision with revision = x
Rake rails: Freeze: gems
# Lock this application to the current gems (by unpacking them into vendor/rails)
Rake rails: unfreeze
# Unlock this application from freeze of gems or edge and return to a fluid use of system gems
Rake rails: Update
# Update both scripts and public/javascripts from rails
Rake rails: Update: javascripts
# Update your javascripts from your current rails install
Rake rails: Update: scripts
# Add new scripts to the application script/directory
Rake stats
# Report code statistics (klocs, etc) from the application
Rake Test
# Test all units and FUNCTIONALS
Rake test: FUNCTIONALS
# Run tests for functionalsdb: Test: Prepare
Rake test: Integration
# Run tests for integrationdb: Test: Prepare
Rake test: plugins
# Run tests for pluginsenvironment
Rake test: Recent
# Run tests for recentdb: Test: Prepare
Rake test: uncommitted
# Run tests for uncommitteddb: Test: Prepare
Rake test: Units
# Run tests for unitsdb: Test: Prepare
Rake TMP: cache: Clear
# Clear all objects in the tmp/cache directory
Rake TMP: Clear
# Clear session, cache, and socket files from the tmp/directory
Rake TMP: Create
# Create the tmp/directory for sessions, cache, and sockets
Rake TMP: Sessions: Clear
# Clear all files in the tmp/sessions directory
Rake TMP: sockets: Clear
# Clear all ruby_sess. * files in the tmp/sessions directory

1.3 scripts
Script/about
# Output current environment information
Script/breakpointer
# Start the breakpoint Server
Script/console
# Start the exchange-type rails Console
Script/destroy
# Deleting files created through generators
Script/generate
#-> Generators
Script/plugin
#-> Plugins
Script/runner
# Execute a task in the rails Context
Script/Server
# Start the Development Mode Server http: // localhost: 3000
// Do not know how to use the following
Script/performance/profiler
Script/performance/benchmarker
Script/process/Reaper
Script/process/spawner

1.4 generators
Ruby script/generate model modelname
Ruby script/generate controller listcontroller show Edit
Ruby script/generate scaffold modelname controllername
Ruby script/generate migration addnewtable
Ruby script/generate plugin pluginname
Ruby script/generate Mailer notification lost_password signup
Ruby script/generate web_service servicename api_one api_two
Ruby script/generate integration_test testname
Ruby script/generate session_migration
Optional:
-P, -- pretend run but do not make any changes.
-F, -- force overwrite files that already exist.
-S, -- Skip skip files that already exist.
-Q, -- Quiet suppress normal output.
-T, -- backtrace debugging: Show backtrace on errors.
-H, -- help show this help message.
-C, -- SVN modify files with subversion. (Note: SVN must be in path)

1.5 plugins
Script/plugin discover
# Discover plugin Repositories
Script/plugin list
# List all available plugins
Script/plugin install where
# Install the € wherea €? Plugin
Script/plugin install-X where
# Install where plugin as SVN external
Script/plugin install http://invisible.ch/projects/plugins/where
Script/plugin update
# Update installed plugins
Script/plugin Source
# Add a source Repository
Script/plugin unsource
# Removes a source Repository
Script/plugin sources
# Lists source Repositories

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.