[Nitro] Passing Data from Template to Controller

Matthew B Gardner weather at speakeasy.net
Sun Dec 16 00:25:05 EST 2007


Hello --
	I'm working on a form to create helpfiles, which seems to be working fine. 
However, the problem I'm having is how to pass entered keywords from the 
template to the controller, where I can manipulate the data. I don't want to 
save the keywords to the database as a string column for the helpfile -- 
instead, I want to take the keywords string and split it up into single 
words, and then add those words to their own table (has_many/belongs_to 
relationship). I can't figure out how to pass that keywords string back to 
the controller though, because it only seems to take data if the variable has 
an Og association. To clarify, I'm trying to do this...

model...
class HelpFile
	attr_accessor :keywords
end

template...
<input type="text" name="keywords" size="45" />

controller...
def create_hfile
	h = request.assign(HelpFile.new)
	kwords = h.keywords.split
	...
end

Thanks for any help or ideas (maybe a better way to do this?),
Matt


More information about the Nitro-general mailing list