Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
RoR Notes
<!-- button to delete an object -->
<% @foo.each do |f| %>
<%= button_to 'delete', f, method: :delete %>
<% 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
# 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.