Ask A Question

Notifications

You’re not receiving notifications from this thread.

Best way to approach these 2?

John asked in Rails

Morning everyone,

I have two issues. First off, I have a meal planning app. I want to display # of recipes #&# mealplans a particular user has (obviously user would have to be logged in). I can use recipes.count, but that counts ALL the recipes in the db regardless of whether they belong to logged in user or not.

Secondly, can <% if signed_in? %> be used in routes.rb? What I am trying to accomplish, is I'd like to have two different root paths, one for signed in users, and one for ppl that don't have accounts/aren't signed in.

What would be the best way to take care of these two things? Thanks to everyone that helps :)

Reply

Forgot to mention, I'm using clearance not devise. The answer to the second question seems to be no, but clearance does provide a method for doing exactly what I was attempting. So, part two solved!

Reply
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 86,946+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.