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.
My Migration Data
create_table :articles do |t|
t.string :title
t.text :tags
t.text :keyword
t.text :content
t.references :project
end
I am running on ruby 1.8.6 entreprise and rails 2.3.5.
Have someone come across this before. Really need some advise.
Thanks
--
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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 24, 6:01 pm, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On May 24, 6:01 pm, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> wrote:
>
>
>
> > On May 24, 6:01 pm, tonymocha
<mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
> To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
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 Did it worked out? On May 24, 9:11 pm, xeon <xeo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > On May 24, 6:01 pm, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Hi Joao, Is the same thing. Project ID and Tags leaves as nil for no reason. On May 25, 4:22 am, Joao Silva <joaodasilvacu...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> wrote:> 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 athttp://api.rubyonrails.org/classes/ActiveRecord/Base.html > > Did it worked out? > > On May 24, 9:11 pm, xeon <xeo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > wrote: > > > > On May 24, 6:01 pm, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On May 25, 7:03 am, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi Joao, > > Is the same thing. Project ID and Tags leaves as nil for no reason. >Are there any warnings in the console ? This really does sound an awful lot like attr_protected or attr_accessible are being used without you knowing it. Fred> On May 25, 4:22 am, Joao Silva <joaodasilvacu...-gM/Ye1E23mwN+BqQ9rBEUg@public.gmane.org> > wrote: > > > > > > > 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 athttp://api.rubyonrails.org/classes/ActiveRecord/Base.html > > > Did it worked out? > > > On May 24, 9:11 pm, xeon <xeo...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > > > wrote: > > > > > On May 24, 6:01 pm, tonymocha <mochat...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> 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-talk@googlegroups.com. > > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > > 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-talk-/JYPxA39Uh4Ykp1iOSErHA@public.gmane.orgm. > > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > > 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.