class Object

Public Instance Methods

<(%= singular_file_name %>_url(<%= singular_file_name %>)) click to toggle source
# File lib/generators/rest_controller/templates/controller.rb, line 35
def <%= singular_file_name %>_url(<%= singular_file_name %>)
  <%= singular_route %> <%= singular_file_name %>
end
destroy() click to toggle source
# File lib/generators/rest_controller/templates/controller.rb, line 20
  def destroy
    respond_with @<%= singular_file_name %>.destroy
  end

  protected
  def find_<%= singular_file_name %>
    @<%= singular_file_name %> = <%= singular_class_name %>.find params[:id]
  end

  def <%= singular_file_name %>_params
    {<% whitelisted_attributes.each do |attribute| %>
      :<%= attribute %> => params[:<%= attribute %>],<% end %>
    }
  end

  def <%= singular_file_name %>_url(<%= singular_file_name %>)
    <%= singular_route %> <%= singular_file_name %>
  end
end
index() click to toggle source
# File lib/generators/rest_controller/templates/controller.rb, line 4
def index
  respond_with <%= singular_class_name %>.all
end

def create
  respond_with <%= singular_class_name %>.create <%= singular_file_name %>_params
end

def show
  respond_with @<%= singular_file_name %>
end
update() click to toggle source
# File lib/generators/rest_controller/templates/controller.rb, line 16
def update
  respond_with @<%= singular_file_name %>.update_attributes <%= singular_file_name %>_params
end