- Ruby : 2.2.0
- Rails : 4.1.7
- backbone-on-rails : 1.1.2.0
- jQuery : 1.11.2
# This script is used with the Ruby on Rails' new project generator: | |
# | |
# rails new my_app -m http://emberjs.com/edge_template.rb | |
# | |
# For more information about the template API, please see the following Rails | |
# guide: | |
# | |
# http://edgeguides.rubyonrails.org/rails_application_templates.html | |
# Install required gems |
class Api::RegistrationsController < Api::BaseController | |
respond_to :json | |
def create | |
user = User.new(params[:user]) | |
if user.save | |
render :json=> user.as_json(:auth_token=>user.authentication_token, :email=>user.email), :status=>201 | |
return | |
else |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
belongs_to :primary_status, :model => 'Status', :foreign_key => 'primary_status_id'
belongs_to :secondary_status, :model => 'Status', :foreign_key => 'secondary_status_id'
-
<% ... %>: Run the code, but don’t print anything. Used for if/then/else/end and array.each loops. You can comment out sections of HTML using <% if false %> Hi there <% end %>. You get a free blank line, since you probably have a newline after the closing %>.
-
<%- ... %>: Run the code, and don’t print the trailing newline. Use this when generating XML or JSON when breaking up .rhtml code blocks for your readability, but don’t want newlines in the output.
-
<%= ... %>: Run the code and print the return value, for example: <%= @foo %> (You did remember the @ sign for controller variables passed to the view, right?). Don’t put if statements inside the <%=, you’ll get an error.
-
<%= h ... %>: Print the code and html escape the output: > becomes >. h() is actually a Ruby function, but called without parens, as Rubyists are apt to do.