daniel
daniel

Reputation: 3115

method error on joining table

Hey I hope you can give me advise on my problem. I got a Course Model, a CourseEnrollment Model and a User Model. In the Course index view it lists all the courses. I got a link_to to join a course. I want to create a new entry on the course_enrollments table.

link_to 'join', current_user.course_enrollments.create(:course_id => course,:user_id => current_user)

In my course_enrollments_controller I have:

def create
@course_enrollment = CourseEnrollment.new(params[:course_id, :user_id])
end

thx for your time

Upvotes: 0

Views: 38

Answers (1)

Lennart Koopmann
Lennart Koopmann

Reputation: 836

Seems like you are really mixing things up here. You are linking to the return value of the create method of a model but I guess you want to link to the "create" action of a controller.

Maybe you should (re-?) read a guide or introduction on Rails first.

Upvotes: 1

Related Questions