Hi All, I am modifying typo so as, I can host multiple blogs on the same typo. And its almost done, except that...i am stuck at one place. When a user posts a new article, depending upon current blog_id, I would like to set the blog_id attribute of @article object. So..in the admin/content_controller.rb: We have: def new_or_edit if request.post? set_article_author save_attachments logger.info("**** and blog id in article is #{@article.blog_id}") if @article.save set_article_categories set_the_flash redirect_to :action => ''show'', :id => @article.id end end end So, just before the actual save, the value printed by logger.info is "**** and blog id in article is 2".But after @article.save is called...whatever may be the current blog_id, the value that gets stored in database is always 1. And I have no clue, why is this. Another pointer. In content.rb model i have defined validate_on_create callback and here goes code for that: def validate_on_create logger.info("$$$ and blog id in article after save is #{self.blog_id}") # my own financial domain kung-fu end so...the above code also prints blog_id as 2 just before saving the article. But again...the value that goes in database is always 1. Any clues, why is this? I am really lost here. Though i can manage this with some crude hack...i don''t want to do that. Can any typo hacker have a look in the code and point me....which filter actually sets the blog_id automagically to default one. gnufied -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/7/06, hemant <gethemant-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi All, > > I am modifying typo so as, I can host multiple blogs on the same typo. > And its almost done, except that...i am stuck at one place. > > When a user posts a new article, depending upon current blog_id, I > would like to set the blog_id attribute of @article object. > > So..in the admin/content_controller.rb: > > We have: > > def new_or_edit > if request.post? > set_article_author > save_attachments > logger.info("**** and blog id in article is #{@article.blog_id}") > if @article.save > set_article_categories > set_the_flash > redirect_to :action => ''show'', :id => @article.id > end > end > end > > So, just before the actual save, the value printed by logger.info is > "**** and blog id in article is 2".But after @article.save is > called...whatever may be the current blog_id, the value that gets > stored in database is always 1. And I have no clue, why is this. > > Another pointer. In content.rb model i have defined validate_on_create > callback and here goes code for that: > > def validate_on_create > logger.info("$$$ and blog id in article after save is #{self.blog_id}") > # my own financial domain kung-fu > end > > so...the above code also prints blog_id as 2 just before saving the > article. But again...the value that goes in database is always 1. > > Any clues, why is this? > > I am really lost here. Though i can manage this with some crude > hack...i don''t want to do that. Can any typo hacker have a look in the > code and point me....which filter actually sets the blog_id > automagically to default one. > > gnufied > > > > > -- > There was only one Road; that it was like a great river: its springs > were at every doorstep, and every path was its tributary. >Ok folks the problem is solved...so please ignore this and the previous mail. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On Sun, 2006-10-08 at 00:11 +0530, hemant wrote:> Ok folks the problem is solved...so please ignore this and the previous mail. >Yeah, okay -- but don''t keep us all in suspense. What was the solution? --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 10/8/06, Craig Beck <craigbeck-sUNYKzuJffo33s2pWanAEQ@public.gmane.org> wrote:> > > Yeah, okay -- but don''t keep us all in suspense. What was the solution? >Oh...i didn''t think somebody anybody else would be interested here. Anyway the issue was with following code snippet: def initialize(*args) super(*args) set_default_blog end def set_default_blog if self.blog_id == nil or self.blog_id == 0 self.blog = Blog.default end end I don''t know how, but the above code resets the blog_id to 1 always, so i changed this code to: def initialize(*args) super(*args) set_default_blog end def set_default_blog if self.blog_id == nil or self.blog_id == 0 self.blog = Blog.set_default_with_user(self.user_id) end end where set_default_with_user is a method that i added to blog.rb. -- There was only one Road; that it was like a great river: its springs were at every doorstep, and every path was its tributary. --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---