[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Saving form fields not working

Rajat Garg

4/11/2008 4:39:00 AM

[Note: parts of this message were removed to make it a legal post.]

I have a form on a page *add_flight.rhtml -*
<%=form_tag({:controller=>"local_flights",:action=>"shared"},
{:id=>"add_flight", :method=>"post"})%>
.....
<%=submit_tag("Add your Flight Request")%>
</form>

Then,* in controller - *
def shared
_flt = params[:fltAvailable]
if !_flt.blank?
@flt = SharedLocalFlight.new(_flt)
@flt.save
end
@fltSharedList = SharedLocalFlight.find(:all)
end

>> This seems to be getting called and then shared.rhtml gets rendered

However, record doesn't get saved to table. There is no error msg in
development.log.

Any ideas on what I am missing here?

Please help.

Thanks,
--
Rajat Garg


Ph: 206-499-9495
Add: 1314 Spring Street, #412
Seattle, WA 98104
Web: http://www.piloto...
-----------------------------------------------------------------------------------------------------
Flying is the second greatest thrill known to man. Landing is the first!

3 Answers

Julian Leviston

4/11/2008 4:50:00 AM

0

I think the problem is with

params[:fltAvailable]

where did you come up with this?

may I suggest (temporarily) replacing shared with this:

def shared
render :text => params.to_yaml
end

and then looking at your html source. It'll show you what the params
key SHOULD be.

Julian

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.ze...


On 11/04/2008, at 2:38 PM, Rajat Garg wrote:

> I have a form on a page *add_flight.rhtml -*
> <%=form_tag({:controller=>"local_flights",:action=>"shared"},
> {:id=>"add_flight", :method=>"post"})%>
> .....
> <%=submit_tag("Add your Flight Request")%>
> </form>
>
> Then,* in controller - *
> def shared
> _flt = params[:fltAvailable]
> if !_flt.blank?
> @flt = SharedLocalFlight.new(_flt)
> @flt.save
> end
> @fltSharedList = SharedLocalFlight.find(:all)
> end
>
>>> This seems to be getting called and then shared.rhtml gets rendered
>
> However, record doesn't get saved to table. There is no error msg in
> development.log.
>
> Any ideas on what I am missing here?
>
> Please help.
>
> Thanks,
> --
> Rajat Garg
>
>
> Ph: 206-499-9495
> Add: 1314 Spring Street, #412
> Seattle, WA 98104
> Web: http://www.piloto...
> -----------------------------------------------------------------------------------------------------
> Flying is the second greatest thrill known to man. Landing is the
> first!


Julian Leviston

4/11/2008 4:50:00 AM

0

By the way, this question should be asked of the rails list, not the
ruby one.

Julian.

Learn Ruby on Rails! Check out the FREE VIDS (for a limited time)
VIDEO #3 out NOW!
http://sensei.ze...


On 11/04/2008, at 2:38 PM, Rajat Garg wrote:

> I have a form on a page *add_flight.rhtml -*
> <%=form_tag({:controller=>"local_flights",:action=>"shared"},
> {:id=>"add_flight", :method=>"post"})%>
> .....
> <%=submit_tag("Add your Flight Request")%>
> </form>
>
> Then,* in controller - *
> def shared
> _flt = params[:fltAvailable]
> if !_flt.blank?
> @flt = SharedLocalFlight.new(_flt)
> @flt.save
> end
> @fltSharedList = SharedLocalFlight.find(:all)
> end
>
>>> This seems to be getting called and then shared.rhtml gets rendered
>
> However, record doesn't get saved to table. There is no error msg in
> development.log.
>
> Any ideas on what I am missing here?
>
> Please help.
>
> Thanks,
> --
> Rajat Garg
>
>
> Ph: 206-499-9495
> Add: 1314 Spring Street, #412
> Seattle, WA 98104
> Web: http://www.piloto...
> -----------------------------------------------------------------------------------------------------
> Flying is the second greatest thrill known to man. Landing is the
> first!


Rajat Garg

4/11/2008 1:11:00 PM

0

[Note: parts of this message were removed to make it a legal post.]

Julian,

I get back -

--- !map:HashWithIndifferentAccess
commit: List your Flight
action: shared
fltAvailable: !map:HashWithIndifferentAccess
from_airport: BFI
cost_type: Cost per person
num_seats: "3"
estimated_flying_time: "1:00"
estimated_cost: "45"
model_name: ""
return_time: 9:00 AM
description: lslkdslks
mfr_name: ""
from_time: 9:00 AM
return_date: "2008-04-16"
from_date: "2008-04-11"
to_airport: HQM
aircraft_id: "73838"
flight_type: One Way


controller: local_flights


Any ideas what the issue is?


PS: What's the list name for Rails ?

Thanks,

On Thu, Apr 10, 2008 at 9:50 PM, Julian Leviston <julian@coretech.net.au>
wrote:

> By the way, this question should be asked of the rails list, not the ruby
> one.
>
> Julian.
>
> Learn Ruby on Rails! Check out the FREE VIDS (for a limited time) VIDEO #3
> out NOW!
> http://sensei.ze...
>
>
> On 11/04/2008, at 2:38 PM, Rajat Garg wrote:
>
> I have a form on a page *add_flight.rhtml -*
> > <%=form_tag({:controller=>"local_flights",:action=>"shared"},
> > {:id=>"add_flight", :method=>"post"})%>
> > .....
> > <%=submit_tag("Add your Flight Request")%>
> > </form>
> >
> > Then,* in controller - *
> > def shared
> > _flt = params[:fltAvailable]
> > if !_flt.blank?
> > @flt = SharedLocalFlight.new(_flt)
> > @flt.save
> > end
> > @fltSharedList = SharedLocalFlight.find(:all)
> > end
> >
> > This seems to be getting called and then shared.rhtml gets rendered
> > > >
> > >
> > However, record doesn't get saved to table. There is no error msg in
> > development.log.
> >
> > Any ideas on what I am missing here?
> >
> > Please help.
> >
> > Thanks,
> > --
> > Rajat Garg
> >
> >
> > Ph: 206-499-9495
> > Add: 1314 Spring Street, #412
> > Seattle, WA 98104
> > Web: http://www.piloto...
> >
> > -----------------------------------------------------------------------------------------------------
> > Flying is the second greatest thrill known to man. Landing is the first!
> >
>
>
>


--
Rajat Garg


Ph: 206-499-9495
Add: 1314 Spring Street, #412
Seattle, WA 98104
Web: http://www.piloto...
-----------------------------------------------------------------------------------------------------
Flying is the second greatest thrill known to man. Landing is the first!