Hi Frederick,

How about :

article = Article.new({:title =>"halo world",:content=>"lorem ipsum",
:tags=>"test,article,fun",:project_id=>"1"})

This example can be found at 
http://api.rubyonrails.org/classes/ActiveRecord/Base.html

Passing data this way requires an hash therefore :title => "bla bla"
as we are dealing with attributes.

Did it worked out?


On May 24, 9:11 pm, xeon <xeo...@gmail.com> wrote:
> Thanks for reply Frederick.
>
> Is a new project. I didn't use any plugins. More funny thing is I
> manually set the attributes without problem.
>
> Example:
> article.project_id=1
>
> It works. However, not for parsing by array. I have did a few project
> before, this is the first time encounter this funny issue. I try this
> on rails console too, it is the same result.
>
> On May 25, 2:49 am, Frederick Cheung <frederick.che...@gmail.com>
> wrote:
>
>
>
> > On May 24, 6:01 pm, tonymocha <mochat...@gmail.com> wrote:
>
> > > Hi,
>
> > > I have come into an odd problem that I couldn't figure out why.
> > > Basically, what I did is to save a record from the form, but there's
> > > some field that parsed to the active record returns as nil.
>
> > > Example:
>
> > > article = Article.new({"title"=>"halo world","content"=>"lorem ipsum",
> > > "tags"=>"test,article,fun","project_id"=>"1"})
> > > #<Article id:nil, title: "halo world",content:"lorem ipsum", tags:nil,
> > > project_id:nil>
>
> > > I don't understand why tags and project_id is nil, while I supplied my
> > > data.
>
> > Are you using attr_protected anywhere (or are any plugins calling it
> > on your models) ?
>
> > Fred
>
> > --
> > You received this message because you are subscribed to the Google Groups 
> > "Ruby on Rails: Talk" group.
> > To post to this group, send email to rubyonrails-t...@googlegroups.com.
> > To unsubscribe from this group, send email to 
> > rubyonrails-talk+unsubscr...@googlegroups.com.
> > For more options, visit this group 
> > athttp://groups.google.com/group/rubyonrails-talk?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups 
> "Ruby on Rails: Talk" group.
> To post to this group, send email to rubyonrails-t...@googlegroups.com.
> To unsubscribe from this group, send email to 
> rubyonrails-talk+unsubscr...@googlegroups.com.
> For more options, visit this group 
> athttp://groups.google.com/group/rubyonrails-talk?hl=en.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-t...@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to