Question

So I'm using the Basecamp HQ (classic) API and a Ruby Wrapper to set up a Rails application to mass add and delete to-do items, milestones and messages.

Right now, I have two controllers--projects and projectSummary (projects has_many projectsummaries, and a projectsummary belongs_to a project) and I want to make it so when a project ID is selected rails will take you to a page that shows the to-do items, milestones and messages.

The projects page works just fine. All the information I want to load about the project is summarized beautifully, however, when trying to link to another page I have been unsuccessful in proceeding.

The error I'm getting is a

undefined method `id'

Even though my rake routes returns

Controller Code

class ProjectsController < ApplicationController
  before_action :set_project, only: [:show, :edit, :update, :destroy]
  before_filter :basecamp_connect
  helper_method :sort_column, :sort_direction

  def index
    @project = Basecamp::Project.find(:all)
  end


  def list
    @projects = @basecamp.projects.find(:all)
  end

  def show
  end

Currently, this is my index.html.erb code where I try to link to a page to show the project summary.

   <% @project.each do |item| %>
   <tr>
     <td><%= item.name %></td>
     <td><%= link_to item.id, project_projectsummary_path(:project_id => @project.id, :id => @project.projectsummary.id) %></td>
     <td><%= item.last_changed_on %></td>
     <td><%= item.created_on %></td>
     <td><%= item.status %></td>

Any ideas what I could do to get this working?

Thanks!

Was it helpful?

Solution

It looks like you call @project when you mean item.

Should this line:

<td><%= link_to item.id, project_projectsummary_path(:project_id => @project.id, :id => @project.projectsummary.id) %></td>

be:

<td><%= link_to item.id, project_projectsummary_path(:project_id => item.id, :id => item.projectsummary.id) %></td>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top