Passing Data from Template to Controller

Hello –
I’m working on a form to create helpfiles, which seems to be working
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
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…

class HelpFile
attr_accessor :keywords


def create_hfile
h = request.assign(
kwords = h.keywords.split


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

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:

def create_hfile
h = request.assign([‘keywords’].split.each do |kw|
h.keywords << KeyWord.create_with(:keyword => kw)

Does that help you?

Matthew B Gardner schreef:

h = request.assign(

Ein Fuchs muß tun, was ein Fuchs tun muß
[email protected]

Hello –

On Sunday 16 December 2007 01:53, Arne B. wrote:

Exactly what I was looking for – thanks so much. I did get an error
the request#post call (undefined method), but it works fine with
accessing request[‘keywords’].

Thanks again, it’s very appreciated.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs