I’m trying to create a link so that if the current user has a project already created, then they just click the ‘Project’ link, and it will take them to their project. Each user can only have one project. If they don’t have a project, then it will instead take them to the form to create one (i.e. the new view/action).
How would I go about this? I apologise, I’m new to rails. At the moment, I am using the following:
<%= link_to 'Project', project_path %>
which works fine if the user already has a project, but says “No route matches {:action=>”show”, :controller=>”projects”}” if one doesn’t exist. I’m not sure where to start – do I add in conditions to the link_to, or is it something I need to put in the controller? Thanks!
1 Answer