I have a devise user model with pro boolean column.I want to build a public page for each of them but only if user is pro.How can i approach it?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s quite straightforward.
First you need to change your user.rb model and add the new column to the attr_accessible, so it looks something like …
Now you can use the following statement to test if a user is a ‘pro’ …
You can also use a before_filter in the controller which displays your public page, you’ll need to read the devise documentation a bit more and perhaps check out this post