Last active
May 24, 2016 19:00
-
-
Save marcusshepp/b5066c0674d49ea9a5f3957d01723082 to your computer and use it in GitHub Desktop.
RoR Notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- button to delete an object --> | |
<% @foo.each do |f| %> | |
<%= button_to 'delete', f, method: :delete %> | |
<% end %> | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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