Reputation: 51
Hi I have posted the code first and the question below
def create
new_tag = Tag.new(name: params[:create_new][:name],
description: "TEST STRING", #TODO
user: @current_user,)
if new_tag.save
create_assignment_tag_association_from_tag_id(params[:assignment_id], new_tag.id)
flash[:success] = I18n.t('tag created successfully')
redirect_to :back
else
flash[:error] = I18n.t('error creating tag')
redirect_to :back
end
end
def create_assignment_tag_association_from_tag_id(assignment_id, tag_id)
puts "assignment_id: #{assignment_id}"
puts "tag_id: #{tag_id}"
tag = Tag.find(tag_id)
create_assignment_tag_association_from_tag(assignment_id, tag)
end
def create_assignment_tag_association_from_tag(assignment_id, t)
if !t.assignment.exists(assignment_id)
assign = Assignment.find(assignment_id)
t.assignments << (assign)
end
end
wrong number of arguments (1 for 0) Rails.root: /Markus
Application Trace | Framework Trace | Full Trace
app/controllers/tags_controller.rb:84:in `create_assignment_tag_association_from_tag'
app/controllers/tags_controller.rb:80:in `create_assignment_tag_association_from_tag_id'
app/controllers/tags_controller.rb:18:in `create'
I'm confused as to why Ruby thinks create_assignment_tag_association_from_tag takes 0 arguments and why it thinks its only getting 1?
Note: I'm only calling create_assignment_tag_association_from_tag_id currently to show that that method takes two arguments and RonR recognizes that it takes two and is getting passed two. Because that call works, I'm confused as to why the second fn call is not working.
Upvotes: 1
Views: 319
Reputation: 239311
The issue isn't create_assignment_tag_association_from_tag
, the issue is inside that function. exists
is wrong. You're after exists?
.
Upvotes: 2