1. Provide the models required 2. Each article can be related to many articles (or none).Provide code for making @article.related_articles work 3. Clean up the code according to rails conventions class ArticleController < ApplicationController def show @article = Article.find(params[:id]) if current_user.roles.map {|r| r.to_s}.include?(''admin'') @info = Info.find(:first, :conditions => "article_id #{@article.id}") else @info = nil end if params[:show_comments] && params[:show_comments] != '''' @comments = Comment.find(:first, :conditions => "article_id #{@article.id}") end if !(params[:hide_related] && params[:hide_related] != '''') @related_articles = @article.related_articles end end end What will be the solution for the above issue? -- Posted via http://www.ruby-forum.com/. -- 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 3 February 2012 10:24, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> 1. Provide the models required > 2. Each article can be related to many articles (or none).Provide code > for making @article.related_articles work > 3. Clean up the code according to rails conventionsReally? you''re just pasting your homework questions directly to the list now without even paraphrasing them?! -- 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.
Michael Pavling wrote in post #1043878:> On 3 February 2012 10:24, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> 1. Provide the models required >> 2. Each article can be related to many articles (or none).Provide code >> for making @article.related_articles work >> 3. Clean up the code according to rails conventions > > Really? you''re just pasting your homework questions directly to the > list now without even paraphrasing them?!Yes, please can you clean up the code according to the rails conventions? -- Posted via http://www.ruby-forum.com/. -- 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 3 February 2012 11:23, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Michael Pavling wrote in post #1043878: >> Really? you''re just pasting your homework questions directly to the >> list now without even paraphrasing them?! > > YesHahaha! At least you''re honest :-) -- 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.
Michael Pavling wrote in post #1043893:> On 3 February 2012 11:23, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> Michael Pavling wrote in post #1043878: >>> Really? you''re just pasting your homework questions directly to the >>> list now without even paraphrasing them?! >> >> Yes > > Hahaha! At least you''re honest :-)Thanks for your compliment. But please... -- Posted via http://www.ruby-forum.com/. -- 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 3 February 2012 11:34, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:>>> Michael Pavling wrote in post #1043878: >>>> Really? you''re just pasting your homework questions directly to the >>>> list now without even paraphrasing them?! >>> >>> Yes >> >> Hahaha! At least you''re honest :-) > > Thanks for your compliment. But please...I''m not doing your homework for you. If you get a certain way through it and get stuck, I''m happy to nudge, but just answering the whole question doesn''t do you any favours. Pass the test on your merits by learning the material; don''t have me pass your tests for you. -- 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.
@Michael is right. We can help you in doing this, in case you are stuck up somewhere, but you must really atleast make an effort. As of point 3, you can consider the following suggestions: 1. `current_user.roles.map {|r| r.to_s}.include?(''admin'')` Consider moving this code to User model by defining an instance function like ''admin?'' so that you can call ''current_user.admin?'' 2. `@info = Info.find(:first, :conditions => "article_id #{@article.id}")` Use associations to define this so that you call `@info = @article.info` 3. `@comments = Comment.find(:first, :conditions => "article_id #{@article.id}")` Again use associations for this. Also, since this is returning a single object, the variable name should be @comment (singular). On Fri, Feb 3, 2012 at 5:08 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 February 2012 11:34, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: > >>> Michael Pavling wrote in post #1043878: > >>>> Really? you''re just pasting your homework questions directly to the > >>>> list now without even paraphrasing them?! > >>> > >>> Yes > >> > >> Hahaha! At least you''re honest :-) > > > > Thanks for your compliment. But please... > > I''m not doing your homework for you. > > If you get a certain way through it and get stuck, I''m happy to nudge, > but just answering the whole question doesn''t do you any favours. > > Pass the test on your merits by learning the material; don''t have me > pass your tests for you. > > -- > 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. > >-- Thanks, Prince -- 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 Fri, Feb 3, 2012 at 3:27 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 3 February 2012 11:23, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> Michael Pavling wrote in post #1043878: >>> Really? you''re just pasting your homework questions directly to the >>> list now without even paraphrasing them?! >> >> Yes > > Hahaha! At least you''re honest :-) >I went back and looked at some other posts by Srimanta. It looks like most of his questions are either homework, or interview questions. -- Greg Akins http://twitter.com/akinsgre -- 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.
I don''t l know why you waste your time -or the group''s time - on this guy. Trying not to say this loser. Oops, just did. On Feb 3, 2012, at 8:07 AM, Greg Akins <angrygreg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Feb 3, 2012 at 3:27 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 3 February 2012 11:23, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Michael Pavling wrote in post #1043878: >>>> Really? you''re just pasting your homework questions directly to the >>>> list now without even paraphrasing them?! >>> >>> Yes >> >> Hahaha! At least you''re honest :-) >> > > I went back and looked at some other posts by Srimanta. It looks like > most of his questions are either homework, or interview questions. > > -- > Greg Akins > http://twitter.com/akinsgre > > -- > 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. >-- 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.
Prince Joseph wrote in post #1043906:> @Michael is right. We can help you in doing this, in case you are stuck > up > somewhere, but you must really atleast make an effort. > > As of point 3, you can consider the following suggestions: > > 1. `current_user.roles.map {|r| r.to_s}.include?(''admin'')` > > Consider moving this code to User model by defining an instance > function > like ''admin?'' so that you can call ''current_user.admin?'' > 2. `@info = Info.find(:first, :conditions => "article_id > #{@article.id}")` > > Use associations to define this so that you call `@info > @article.info` > 3. `@comments = Comment.find(:first, :conditions => "article_id > #{@article.id}")` > > Again use associations for this. Also, since this is returning a > single > object, the variable name should be @comment (singular). > > > > On Fri, Feb 3, 2012 at 5:08 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > >> > Thanks for your compliment. But please... >> 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. >> >> > > > -- > Thanks, > PrinceThanks for your hint, I have tried the problem and please check this whether it is correct or not Models requires: class Article < ActiveRecord::Base has_many :related_articles, :dependent => :destroy has_many :info, :dependent => :destroy has_many :comments, :dependent => :destroy end class RelatedArticle < ActiveRecord::Base belongs_to :article end class Info < ActiveRecord::Base belongs_to :article end class Comment < ActiveRecord::Base belongs_to :article end Each article can be related to many articles (or none). -- YES Cleaning up the code: class ArticleController < ApplicationController def show @article = Article.find(params[:id]) if current_user.roles.map {|r| r.to_s}.include?(''admin'') @info = @article.info.first else @info = nil end if params[:show_comments] && params[:show_comments] != '''' @comments = @article.comments.first end if !(params[:hide_related] && params[:hide_related] != '''') @related_articles = @article.related_articles end end end -- Posted via http://www.ruby-forum.com/. -- 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 Fri, Feb 3, 2012 at 5:12 AM, Scott Eisenberg <scott2-5XihT3XKyOKakBO8gow8eQ@public.gmane.org> wrote:> I don''t l know why you waste your time -or the group''s time - on this guy. > > Trying not to say this loser. Oops, just did. >Scott. Are you calling me a loser for posting the comments about Srimanta? -- Greg Akins http://twitter.com/akinsgre -- 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 3 February 2012 13:15, Greg Akins <angrygreg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Fri, Feb 3, 2012 at 5:12 AM, Scott Eisenberg <scott2-5XihT3XKyOKakBO8gow8eQ@public.gmane.org> wrote: >> I don''t l know why you waste your time -or the group''s time - on this guy. >> >> Trying not to say this loser. Oops, just did. > > Scott. Are you calling me a loser?Not if you read it thus: "I don''t l know why you waste your time on this loser." But it''s a bit of a strong judgement for my tastes... personally, I think he''s a bit of a chancer, trying to get better grades by getting people to do his work for him. Wouldn''t go so far as to bandy around insults. -- 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 Fri, Feb 3, 2012 at 7:12 AM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Not if you read it thus: > "I don''t l know why you waste your time on this loser." >OK, I''ll read it that way ;-) Incidentally, even though I was shocked by Srimanta''s request, I did learn something from Prince''s response. -- Greg Akins http://twitter.com/akinsgre -- 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.
No sir. Not you! Apologies if I gave you that impression. On Feb 3, 2012, at 8:15 AM, Greg Akins wrote:> On Fri, Feb 3, 2012 at 5:12 AM, Scott Eisenberg <scott2-5XihT3XKyOKakBO8gow8eQ@public.gmane.org> wrote: >> I don''t l know why you waste your time -or the group''s time - on this guy. >> >> Trying not to say this loser. Oops, just did. >> > > Scott. Are you calling me a loser for posting the comments about Srimanta? > > -- > Greg Akins > http://twitter.com/akinsgre > > -- > 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. >-- 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.
I agree that insults in general are bad. This rare time it seemed deserved. A few questions are fine. Being a chump for someone who won''t do their homework is beyond the pale. Programmers don''t always have good local resources for help. As a student, he should have a professor, TA, fellow students to lean on. I just think in this case we''re being played. Certainly ''nuff said on this "chancer" (whatever that is :-)) for now. On Feb 3, 2012, at 10:12 AM, Michael Pavling wrote:> On 3 February 2012 13:15, Greg Akins <angrygreg-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On Fri, Feb 3, 2012 at 5:12 AM, Scott Eisenberg <scott2-5XihT3XKyOKakBO8gow8eQ@public.gmane.org> wrote: >>> I don''t l know why you waste your time -or the group''s time - on this guy. >>> >>> Trying not to say this loser. Oops, just did. >> >> Scott. Are you calling me a loser? > > Not if you read it thus: > "I don''t l know why you waste your time on this loser." > > But it''s a bit of a strong judgement for my tastes... personally, I > think he''s a bit of a chancer, trying to get better grades by getting > people to do his work for him. Wouldn''t go so far as to bandy around > insults. > > -- > 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. >-- 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 Fri, Feb 3, 2012 at 11:00, Scott Eisenberg <scott2-5XihT3XKyOKakBO8gow8eQ@public.gmane.org> wrote:> Certainly ''nuff said on this "chancer" (whatever that is :-)) for now.Heh. I had to go look it up too. http://www.merriam-webster.com/dictionary/chancer says: ===8<---cut here--- British : a scheming opportunist Examples of CHANCER <a two-faced chancer, he doesn''t hesitate to dump people when they are no longer of any use> <betrayed by a chancer who, she mistakenly thought, was her friend> First Known Use of CHANCER 1959 Related to CHANCER Synonyms: chameleon, acrobat [British], opportunist, temporizer, timeserver, trimmer, weathercock Related Words: egoist, egotist, self-seeker; conniver, machinator, plotter, schemer Near Antonyms: altruist ===8<---cut here--- Truly we are two (and then some) nations divided by a common language.... -Dave -- Dave Aronson: Available Cleared Ruby on Rails Freelancer (NoVa/DC/Remote) -- see www.DaveAronson.com, and blogs at www.Codosaur.us, www.Dare2XL.com, www.RecruitingRants.com -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On Feb 3, 2012, at 3:13 PM, Srimanta Chakraborty wrote:> Prince Joseph wrote in post #1043906: >> @Michael is right. We can help you in doing this, in case you are stuck >> up >> somewhere, but you must really atleast make an effort. >> >> As of point 3, you can consider the following suggestions: >> >> 1. `current_user.roles.map {|r| r.to_s}.include?(''admin'')` >> >> Consider moving this code to User model by defining an instance >> function >> like ''admin?'' so that you can call ''current_user.admin?'' >> 2. `@info = Info.find(:first, :conditions => "article_id >> #{@article.id}")` >> >> Use associations to define this so that you call `@info >> @article.info` >> 3. `@comments = Comment.find(:first, :conditions => "article_id >> #{@article.id}")` >> >> Again use associations for this. Also, since this is returning a >> single >> object, the variable name should be @comment (singular). >> >> >> >> On Fri, Feb 3, 2012 at 5:08 PM, Michael Pavling <pavling-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> >> wrote: >> >>>> Thanks for your compliment. But please... >>> 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. >>> >>> >> >> >> -- >> Thanks, >> Prince > > Thanks for your hint, I have tried the problem and please check this > whether it is correct or not > > Models requires: > class Article < ActiveRecord::Base > has_many :related_articles, :dependent => :destroy > has_many :info, :dependent => :destroy > has_many :comments, :dependent => :destroy > end > class RelatedArticle < ActiveRecord::Base > belongs_to :article > end > class Info < ActiveRecord::Base > belongs_to :article > end > class Comment < ActiveRecord::Base > belongs_to :article > end > > Each article can be related to many articles (or none). -- YES > > > Cleaning up the code: > > class ArticleController < ApplicationController > def show > @article = Article.find(params[:id]) > if current_user.roles.map {|r| r.to_s}.include?(''admin'') > @info = @article.info.first > else > @info = nil > end > if params[:show_comments] && params[:show_comments] != '''' > @comments = @article.comments.first > end > if !(params[:hide_related] && params[:hide_related] != '''') > @related_articles = @article.related_articles > end > end > end > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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. >Dud i will give you 2 hints : - - RTFM - - try .blank? method # if params[:show_comments] && params[:show_comments] != '''' can be wrote as unless params[:show_comments].blank? Alecslupu -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJPLGd0AAoJEAa2YjEk8CRGW6cIAJD3PdHXOTFUYFrN7lVWlKSh h+Pj1kBAPqUfJqaRDYP+QeJZgyRqcHDd9e9iRZqDLvwjAT369Uk7kB79aTHRjhKh gzlwtyJhG6OaRSguyO29qba6ofXaX63G1T01u+FpWWx5LdsxilGwgXqVL+tdZqoE CbUq2CjUWpIUTQ6ILlutAWUUNH7UtUlsteeBrAtWRR2uGB1LIBN0/0HnxCxmKA0X mSltDek0aAJy8A+368s3TYxZa1Ed4oLjdxaF4Pfvd7mfIAXsLnd8S7RwN5YatToP Mv5envrYNjIymmb8lwnLigoFnwSX8tR8xTnDMFT3patVgvRPnykpJcKU4QcgZoc=tuad -----END PGP SIGNATURE----- -- 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.
Hi, I am a new guy in ruby on rails. I am using this forum to get help to learn this. So please don''t think that I am a loser or chancer. In this world everybody tries to get chance. If you don''t want to help then just ignore it. Thanks -- Posted via http://www.ruby-forum.com/. -- 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 6 February 2012 06:02, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> So please don''t think that I am a loser or chancer.What would _you_ call someone who tries to cheat their way through their qualifications? -- 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.
Michael Pavling wrote in post #1044267:> On 6 February 2012 06:02, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> > wrote: >> So please don''t think that I am a loser or chancer. > > What would _you_ call someone who tries to cheat their way through > their qualifications?Thanks for your comment... -- Posted via http://www.ruby-forum.com/. -- 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.
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Man... I am new to ruby / rails myself ... But ... I try to RTFM .. and also... i have actually bought some books... But all the stuff you''re asking in this thread is here ... Rails AntiPatterns: Best Practice Ruby on Rails Refactoring (Addison-Wesley Professional Ruby Series) // http://www.amazon.com/Rails-AntiPatterns-Refactoring-Addison-Wesley-Professional/dp/0321604814/ref=sr_1_fkmr1_1?ie=UTF8&qid=1328515732&sr=8-1-fkmr Also, before starting books ... i have started the hardway ... wrote a piece of code ... try to make it cleaner ... and start refactoring it ... ''til i''ll be satisfied with my work ... You can''t become a guru / specialist if you rely on others to fix your own problems. I guess that you''d have received a better help if instead of asking "What will be the solution for the above issue?" you''d have at least asking for an opinion : "Guys, i had this code, I have refactored it like this... Is there something else I can improve ?" Alecslupu On Feb 6, 2012, at 9:55 AM, Srimanta Chakraborty wrote:> Michael Pavling wrote in post #1044267: >> On 6 February 2012 06:02, Srimanta Chakraborty <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> >> wrote: >>> So please don''t think that I am a loser or chancer. >> >> What would _you_ call someone who tries to cheat their way through >> their qualifications? > > Thanks for your comment... > > -- > Posted via http://www.ruby-forum.com/. > > -- > 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. >-----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.17 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJPL4xNAAoJEAa2YjEk8CRGCdkIAJjjr91k5pFP2ufkKucga6Us czxHCmefAenvad3/PwIlS/wS8m+54rbpYfGxFgjkW+T6P91AFnEdm7dwWJ6RF63L JKK0r9I9X2JBQWO1jpSmaqiGXgtehXzjuQVmzuVVsIo34kcHdW/g2bKWOajkVWMi SDNSr+EeGvrR+kYVrWzhKGouN13R0MP3PSf60mzR0zSgFmR8w+ausPPwlKbGCmcX VCyZAzwuhucY1TyriQ5GkPod+MB7KJblH0Ce9MjlOFJffYx7wLX5iTUS2hM3Sx4n yV5YPAsGXYUq2o6vbaAGIWpMfN7scr8RVEVjwgyILsIzikyQyvyy3dXvz8ShEIw=Vl0E -----END PGP SIGNATURE----- -- 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 Feb 6, 12:02 am, Srimanta Chakraborty <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi, > I am a new guy in ruby on rails. I am using this forum to get help > to learn this. So please don''t think that I am a loser or chancer. In > this world everybody tries to get chance. If you don''t want to help then > just ignore it. >Asking for the answers != getting help to learn. See ESR''s essay for more: http://catb.org/esr/faqs/smart-questions.html In short, you''ll get far more positive responses if you demonstrate that you''ve actually attempted to solve the problem *before* posting, instead of just copying and pasting. --Matt Jones -- 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.