Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3723726
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T06:22:43+00:00 2026-05-19T06:22:43+00:00

I’ve created in rails(3) a new html page in my project model named contact.html.erb

  • 0

I’ve created in rails(3) a new html page in my project model named contact.html.erb and I am interested in linking to it from a different page, i’ve added the code:

<%= link_to 'contact', contact_project_path(@project) %>

Project is a model that belongs_to a User (which is the contact in the contact page).

This link gives me an error message saying that contact_project_path doesnt exist. I know I need to define it somewhere but I don’t know where or how. I want the page to be specific per project. I’ve created an action in the project_controler named contact and left it empty.

What am i missing?

I’ve searched for a soloution for quite some time and haven’t found an answer to this question anywhere else. I’m aware its a little bit basic but I have no other options.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T06:22:45+00:00Added an answer on May 19, 2026 at 6:22 am

    -REVISED ANSWER-
    Based on comments I see you’re not trying to associate a contact model, just a view. In that case, you still need to change the routes file, but you need to decide if you want to get a single contact page for all projects, or one contact view per project. IE:

    # Collection Contact
    example.com/projects/contact # IE One contact view for all projects
    
    # Member Contact
    example.com/projects/1/contact # IE One contact view per project
    

    Either way you need to use a block for your project resource in your routes file. So, if you want there to be one contact page for the collection (all projects), do:

    resources :projects do
      collection do
        get 'contact'
      end
    end
    

    Or, if you want one contact view per member (one per project) do:

    resources :projects do
      member do
        get 'contact'
      end
    end
    

    Either way this will give you helper methods which you can put into link_to

    For the collection it should be contact_projects_path (no arguments), and for members it should be contact_project_path(@project) (pass in the project as an argument.

    You can use get post put delete or match as a parameter in a collection or member block, that just tells Rails what kind of request to handle at that URL, and what helpers to generate. For normal views you want a GET request.

    I hope this finally answers your question 🙂

    -ORIGINAL ANSWER-

    This is for routing to a MODEL, not just a view

    Add to your routes.rb:

    resources :projects do
      resource :contact
    end
    

    If I understand your question correctly, that should create a helper called project_contact_path().

    This record will be projects/123/contact.

    If you want more than one contact per project, you’ll need to make it plural (resource :contacts). Then your records would look like projects/123/contacts/123.

    See http://guides.rubyonrails.org/routing.html

    You would link to this using link_to( project_contact_path(@project) ) if there’s only one contact per project, or link_to( project_contact_path(@project,@contact) ) if there are multiple contacts per project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Basically, what I'm trying to create is a page of div tags, each has
That's pretty much it. I'm using Nokogiri to scrape a web page what has
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.