Skip to content

Instantly share code, notes, and snippets.

@marcusshepp
Last active May 24, 2016 19:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcusshepp/b5066c0674d49ea9a5f3957d01723082 to your computer and use it in GitHub Desktop.
Save marcusshepp/b5066c0674d49ea9a5f3957d01723082 to your computer and use it in GitHub Desktop.
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