That's what I have so far to save the requirement. I can save the
requirement fine. However, if the user inputs a title for a requirement
that already exists, I want to check that, and add the user's post to
THAT requirement (that already exists). How would I do this? Requirement
has only one column 'title'...
I've tried
@requirements = Requirement.find(:all)
@requirements.each do |req|
if(params[:requirement].include?(req.title))
curr_req = req
end
end
if curr_req
@post = curr_req.posts.build(params[:post])
if @post.save
redirect_to :action => :index
else
redirect_to :action => :new_requirement
end
else
@requirement = Requirement.new(params[:requirement])
@post = @requirement.posts.build(params[:post])
if @post.save
redirect_to :action => :index
else
redirect_to :action => :new_requirement
end
end
Doesn't work... I also received an error: Unknown key(s): title
That's what I have so far to save the requirement. I can save the
requirement fine. However, if the user inputs a title for a requirement
that already exists, I want to check that, and add the user's post to
THAT requirement (that already exists). How would I do this? Requirement
has only one column 'title'...
I've tried
@requirements = Requirement.find(:all)
@requirements.each do |req|
if(params[:requirement].include?(req.title))
curr_req = req
end
end
That would work if you had instead said params[:requirement][:title]
== req.title (not sure what you were thinking would happen with
include?)
This is an incredibly inefficient way of doing things when you could
just do curr_req = Requirement.find_by_title params[:requirement]
[:title].
That would work if you had instead said params[:requirement][:title]
== req.title (not sure what you were thinking would happen with
include?)
This is an incredibly inefficient way of doing things when you could
just do curr_req = Requirement.find_by_title params[:requirement]
[:title].
Fred
Thanks for your continued help Fred, really appreciate it.
Pretty new to this stuff, so I'm still trying to learn.
That would work if you had instead said params[:requirement][:title]
== req.title (not sure what you were thinking would happen with
include?)
This is an incredibly inefficient way of doing things when you could
just do curr_req = Requirement.find_by_title params[:requirement]
[:title].
Fred
Thanks for your continued help Fred, really appreciate it.
Pretty new to this stuff, so I'm still trying to learn.