Problem inserting date_select values in the database

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

controller looks like this.
def create
@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

this is the date_select field in my form

          <%= date_select :post, :birthdate, :order => [:month,

:day, :year], :start_year => (Date.today -
99.years).strftime(’%Y’).to_i, :end_year =>
Date.today.strftime(’%Y’).to_i %>

Am i doing something wrong?

thanks

On Apr 26, 8:20 pm, Sam G. [email protected]
wrote:

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

[snip]

Am i doing something wrong?

Not at first glance. Define nothing (date parameter is not in the
request parameters at all, object does not save at all, object does
save but the birthdate attribute is not set …). If the browser is
not submitting the date parameters at all, a common cause is invalid
html.

Fred

It doe not insert anything into the database. I guess it’s what you
describe as “save but the birthdate attribute is not set”

Frederick C. wrote:

On Apr 26, 8:20�pm, Sam G. [email protected]
wrote:

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

[snip]

Am i doing something wrong?

Not at first glance. Define nothing (date parameter is not in the
request parameters at all, object does not save at all, object does
save but the birthdate attribute is not set …). If the browser is
not submitting the date parameters at all, a common cause is invalid
html.

Fred

Solved the problem. I was using attr_accessible and forgot to include
the date_select field in it. Stupid of me.

James B. wrote:

Sam G. wrote:

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

controller looks like this.
def create
@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

What does putting ‘print params[:post].to_yaml’ just before the
flash[:notice] show on the console?

Sam G. wrote:

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

controller looks like this.
def create
@post = Post.new(params[:post])
if @post.save
flash[:notice] = ‘Post was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end

What does putting ‘print params[:post].to_yaml’ just before the
flash[:notice] show on the console?

Solved the problem. I was using attr_accessible and forgot to include
the date_select field in it. Stupid of me.

thanks

Frederick C. wrote:

On Apr 26, 8:20�pm, Sam G. [email protected]
wrote:

I’m trying to insert the selected values of the date_select object in
the database but I’m getting nothing

[snip]

Am i doing something wrong?

Not at first glance. Define nothing (date parameter is not in the
request parameters at all, object does not save at all, object does
save but the birthdate attribute is not set …). If the browser is
not submitting the date parameters at all, a common cause is invalid
html.

Fred