[Nitro] Passing Data from Template to Controller

Arne Brasseur arne at arnebrasseur.net
Sun Dec 16 01:53:14 EST 2007

You can access the individual fields in the request to do your own 
processing. I think this is what you're looking for.

Something to this effect:

<form method="post" action="...">
<input type="text" name="keywords" size="45" />


def create_hfile
  h = request.assign(HelpFile.new)
  request.post['keywords'].split.each do |kw|
    h.keywords << KeyWord.create_with(:keyword => kw)

Does that help you?

Matthew B Gardner schreef:
> 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
> _______________________________________________
> Nitro-general mailing list
> Nitro-general at rubyforge.org
> http://rubyforge.org/mailman/listinfo/nitro-general

Ein Fuchs muß tun, was ein Fuchs tun muß
arne at arnebrasseur.net

More information about the Nitro-general mailing list