i know there is a better way to do this..
i am running a logging type program using rails..
a macromedia director program sends some post data to:
http://host/logger
and if the data is okay, it makes a new entry into the database..
the problem is:
when i first wrote it, i had a form that i used to make sure all the
data was moving around okay..
what i did was, named all the form elements as "entry[name]"..
this passed a hash to the controlller.. and i did something like:
@entry=Entry.new(@params[:entry])
and everything worked great..
we just found out that director has a problem passing such data to the
controller, and i had to remove all of the hash entries, and just called
them:
realm, user, status, message..
when i did something like:
@entry=Entry.new(@params)
i had a problem with the number of arguments..
the snipped of code at the bottom of this shows how i handled this..
it works and all, but i want to come up with a better way to do this
when i have a HUGE form that may run into this problem..
so, is there a more elegant way to do this?
thanks so much!
---code snippet---
class LoggerController < ApplicationController
def index
if request.post? and @params[:usage]=="logger"
@data=@params
@entry =
Entry.new(:user=>params[:user],:realm=>params[:realm],:status=>params[:status],:message=>params[:message])
@entry.save
else
@message="illegal access.. data not logged..."
end
end
end
--
Posted via http://www.ruby-forum.com/.