marcus-s
5/4/2016 - 2:25 PM

RoR Notes

RoR Notes

# schema.rb 
create_table "foo", :force => true do |t|
  t.integer "user_id"
end

# foo_controller.rb
class FooController < ApplicationController
  def something
    # find the first foo with the same user_id as the current user.
    @foo = Foo.first(:conditions => ["user_id = ?", @user.id])
  end
end
class FooController < ApplicationController
  # needed this line in order to make an ajax call to a controller I wrote.
  # was trying to authenticate the request but couldn't.
  # this allowed for it to skip that step and give me the resource.
  skip_before_filter :authorize_action, :only => :get_user_destinations
  
  
end
<!-- button to delete an object --> 

<% @foo.each do |f| %>
    <%= button_to 'delete', f, method: :delete %>
<% end %>