Skip to content

Instantly share code, notes, and snippets.

@mfifth
Last active May 20, 2016 00:56
Show Gist options
  • Select an option

  • Save mfifth/db08c939bfde2926691d4eda2a637c9a to your computer and use it in GitHub Desktop.

Select an option

Save mfifth/db08c939bfde2926691d4eda2a637c9a to your computer and use it in GitHub Desktop.
module ApplicationHelper
require 'pry'
def admins_only(&block)
block.call if current_user.try(:admin?)
end
def author_only(&block)
binding.pry
block.call if current_user == @topic.author.email
end
end
No such file to load -- pry
Extracted source (around line #2):
1
2
3
4
5
6
module ApplicationHelper
require 'pry'
def admins_only(&block)
block.call if current_user.try(:admin?)
end
From: /home/ubuntu/workspace/app/helpers/application_helper.rb @ line 8 ApplicationHelper#author_only:
7: def author_only(&block)
=> 8: binding.pry
9: block.call if current_user == @topic.author.email
10: end
[1] pry(#<#<Class:0x007fda3e84c608>>)> current_user
User Load (0.2ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? ORDER BY "users"."id" ASC LIMIT 1 [["id", 2]]
=> #<User:0x007fda38e59100
id: 2,
email: "user@forums.com",
encrypted_password: "$2a$11$zUKy8XJnFahKuVB/QOBDjOxxjA.PsuxvxQ74k4ieiRalfW.OV5yj2",
reset_password_token: nil,
reset_password_sent_at: nil,
remember_created_at: nil,
sign_in_count: 5,
current_sign_in_at: Fri, 20 May 2016 00:14:23 UTC +00:00,
last_sign_in_at: Thu, 19 May 2016 23:40:45 UTC +00:00,
current_sign_in_ip: "45.50.5.253",
last_sign_in_ip: "45.50.5.253",
created_at: Wed, 18 May 2016 05:14:54 UTC +00:00,
updated_at: Fri, 20 May 2016 00:14:23 UTC +00:00,
admin: false>
[2] pry(#<#<Class:0x007fda3e84c608>>)> @topic.author.email
=> "admin@forums.com"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment