[Rails] Re: link_to_remote is not works for me
I USED the remote function method and fixed that error -- 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.
[Rails] how do i define and access custom function in model
i need to define a custom finction in model which is named as "count_remaked_users". when i try to access that function from view (< %=User.count_remaked_users%>) i'm getting "undefined method" error. any clue for this?. -- 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.
[Rails] Re: If controller doesn't exist: search database for its nam
Michael Pavling wrote: > On 11 May 2010 21:03, sso wrote: >> if somebody enters a a controller that doesn't exist a database search >> runs and looks for the controller name >> >> Is this possible without violating any "rules"? > > You would probably be able to do something by catching 404 errors in > your application controller and then punting them off to a method that > tries to guess what the user meant. Google for "Rails 404" for a few > methods to try. Actually, no 404 catching is necessary. All you need is a catchall route that sends '/:category' off to a search action. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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-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.
[Rails] link_to_remote is not works for me
link_to_remote is not works for me here my codes in my user controller - def edit puts "= test output =" end - In view <%= link_to_remote "Vote",:controller=>"poem",:action=>"vote_for_poem"%> -- when i click the link then i'm getting ActionController::UnknownAction (No action responded to 3. Actions: create, destroy, edit, index, new, show, update, and vote_for_poem): anybody please help me -- 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.
[Rails] How to add an after_save callback on runtime on a particular instance
class User < AR end user = User.new Let's say that I have a user instance with me. After this record is saved I want an after_save callback which would print the id of the record. The only catch is that I am not allowed to change the User class. How can I accomplish my goal? Is that even possible to add an after_save callback on a particular instance object. Any metaprogramming hack. I'm sure ruby does provide some tool. This would be a trivial issue if I were allowed to change the User class but I am not. -- 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.
[Rails] Re: Structuring Active Record relationships
Thinking about it some more, I now think I should have separate Expense, Vendor and Account tables with the following relationships: class Expense has_one Vendor class Vendor has_many Accounts belongs_to Expense class Account belongs_to Vendor Then an Expense record can get Accounts through Vendor. .. or something like that. Am I getting warmer? Thanks in Advance, Richard On May 11, 8:57 pm, RichardOnRails wrote: > Hi, > > I have three tables: Expenses, Vendors and Vendor _Accounts > > It should operate as follows: > When a new Expense record is created, > A vendor is selected from a drop-down of Vendors and, > An account is selected from a drop-down of Vendor_Accounts where > Vendor_Accounts#vender == selected vendor > > So I should have a structure something like: > class Expense > has_one Vendor > > class Vendor > has_many Vendor_Accounts where Vendor#id == Vendor_Accounts#vendor > belongs_to Expense > > class Vendor_Account > belongs_to Vendor > > I don’t think I should have Expense, Vendor and Account tables because > the accounts defined by each vendor bear no relationship with the > other vendors’ account beyond the mere concept of “account”. > > Does this make sense, and if so, how precisely should I describe > these relationships? Am I close with the above idea? > > BTW, I'm running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox > 3.6.2, Firebug 1.5.3, > MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15 > > Thanks in Advance, > Richard > > -- > 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.
[Rails] Re: Ahhh .count!
David Zhu wrote: >> This seems like a good use case for has_many :through. > > > It sounds like an excellent case for has_many :through! > > haha i just did it using that method, it works great. thanks guys You're welcome! > > (Oh, am i posting right?) Yup. Best, -- Marnen Laibow-Koser http://www.marnen.org mar...@marnen.org -- 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-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.
[Rails] rails 3 release date
When is the stable version of rails 3 being released? -- 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.
[Rails] Rails 3: Change validation error formatting?
Hello, I've been reading that Rails 3 offers a bunch of new validation features. Is there a way to customize the validation error formatting? For example, I prefer to style the elements surrounding a form input containing an error, not just the input itself. Also, I might like to define my own class names for styling these elements, for example if they don't conform to my naming standards. Is this easier in Rails 3 than in 2? I found a few articles about new validation functionality, but they seem to be formatting the old way. 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-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.
[Rails] Structuring Active Record relationships
Hi, I have three tables: Expenses, Vendors and Vendor _Accounts It should operate as follows: When a new Expense record is created, A vendor is selected from a drop-down of Vendors and, An account is selected from a drop-down of Vendor_Accounts where Vendor_Accounts#vender == selected vendor So I should have a structure something like: class Expense has_one Vendor class Vendor has_many Vendor_Accounts where Vendor#id == Vendor_Accounts#vendor belongs_to Expense class Vendor_Account belongs_to Vendor I don’t think I should have Expense, Vendor and Account tables because the accounts defined by each vendor bear no relationship with the other vendors’ account beyond the mere concept of “account”. Does this make sense, and if so, how precisely should I describe these relationships? Am I close with the above idea? BTW, I'm running Rails 2.3.5, Ruby 1.8.6, WinXP-Pro/SP3, Firefox 3.6.2, Firebug 1.5.3, MySQL 5.0.37-community-nt, Mongrel, Apache HTTP Server 2.2.15 Thanks in Advance, Richard -- 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.
[Rails] Rails 3: perform controller action upon selecting menu item (UJS?)
In Rails 3, I have a form that has a menu on it. I would like to render an area containing text fields within the form differently depending on what's selected in the menu. Prior to Rails 3, one way it appears I could do this is by using observe_field on the menu and call an action in my controller that renders the appropriate partial which could then be swapped into a div in my form. In Rails 3, I'm not getting any further with this approach than the following error when I try to display the view the first time: undefined method `observe_field' Am I on the right track, or is there a new and improved, UJS-correct way of doing this in Rails 3? -- 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.
[Rails] Re: Ahhh .count!
> This seems like a good use case for has_many :through. It sounds like an excellent case for has_many :through! haha i just did it using that method, it works great. thanks guys (Oh, am i posting right?) -- 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.
[Rails] Re: Why does Object.const_defined?() returns false in this case?
Thanks for the quick answer! Yes, I am in development mode and this is actually the problem as you described. How can I force Rails even in development mode to load ALL classes, is that possible? Thank you, ms On 12 Mai, 00:19, Frederick Cheung wrote: > On May 11, 9:32 pm, ms wrote: > > > Object.const_defined?("DemandType") => false > > Object.const_get("DemandType") => Class > > > Why does const_defined?() returns false in this case? I have also > > tested it in rails console, but it was not successful. I could also > > work with const_get() alone and catch the NameError exception, but I > > would really like to know why const_defined?() is not working. > > Are you in development mode ? If so classes aren't loaded until they > are needed. const_defined? is returning false because the class does > not exist in memory. const_get triggers Rails' const_missing handler > which loads the class (and so const_get can then return it) > > 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 at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] how to redirect
thank u! must have overseen that tom On Tue, 2010-05-11 at 20:40 +0100, Colin Law wrote: > On 11 May 2010 16:48, tom wrote: > > hi, > > > > i have a "notes" model which i include in various other views via > > partial. how can i tell / what do i need to do in order to redirect the > > user back to the view where he was instead to the index-view of the > > notes? > > Have a look at the docs for redirect_to and you will see that there is > a :back option to go back to where you were. > > Colin > -- 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.
[Rails] Re: Why does Object.const_defined?() returns false in this case?
On May 11, 9:32 pm, ms wrote: > Object.const_defined?("DemandType") => false > Object.const_get("DemandType") => Class > > Why does const_defined?() returns false in this case? I have also > tested it in rails console, but it was not successful. I could also > work with const_get() alone and catch the NameError exception, but I > would really like to know why const_defined?() is not working. > Are you in development mode ? If so classes aren't loaded until they are needed. const_defined? is returning false because the class does not exist in memory. const_get triggers Rails' const_missing handler which loads the class (and so const_get can then return it) 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 at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: hostingrails.com appears to have had an ownership change
We have had a very similar experience, with two separate hostingrails sites. We eventually moved all our sites over to railsplayground.net and been happy with them so far. I've never had a hosting company switch me to a new server without thoroughly ensuring everything works and getting my approval before throwing the switch. Hostingrails on the other hand, arrogantly just moved my files over and sent me an email notification that my IP has changed. Then all hell broke loose. SMTP failures, site down for hours at a time, multiple times a day, tried to contact Support continuously. The went on for over 2 weeks, as we moved to a new hosting company. I have lost a major Beta customer in the process. I was actually hung-up on by the "customer support" manager, Derek, after I asked the support technician to transfer me to his boss, because I dared to say the situation was "bullshit" ("I'm terminating this call because of your bad language"). Support tickets are closed without being resolved. Hostingrails used to have exceptional support. Now its in the toilet. In an attempt to give them one last chance, I tried to contact "management" but there's none listed on their website. I called their sales and support lines and asked for the name of the company president, and was refused that information. Quite unbelievable. -- 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.
[Rails] Re: hostingrails.com appears to have had an ownership change
We have had a very similar experience, with two separate hostingrails sites. We eventually moved all our sites over to railsplayground.net and been happy with them so far. I've never had a hosting company switch me to a new server without thoroughly ensuring everything works and getting my approval before throwing the switch. Hostingrails on the other hand, arrogantly just moved my files over and sent me an email notification that my IP has changed. Then all hell broke loose. SMTP failures, site down for hours at a time, multiple times a day, tried to contact Support continuously. The went on for over 2 weeks, as we moved to a new hosting company. I have lost a major Beta customer in the process. I was actually hung-up on by the "customer support" manager, Derek, after I asked the support technician to transfer me to his boss, because I dared to say the situation was "bullshit" ("I'm terminating this call because of your bad language"). Support tickets are closed without being resolved. Hostingrails used to have exceptional support. Now its in the toilet. In an attempt to give them one last chance, I tried to contact "management" but there's none listed on their website. I called their sales and support lines and asked for the name of the company president, and was refused that information. Quite unbelievable. -- 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.
Re: [Rails] any way to stop notify(method) in a model ?
On 11 May 2010 21:53, Bob Smith wrote: > I am adding a function to check for 2 digit dates and change them into > 4 digit before a Date.new has time to choke on it. My model is : > > class Person < ActiveRecord::Base > belongs_to :household > > def before_validation > # debugger > self.month_int = self.month.to_i > self.day_int = self.day.to_i > self.year_int = self.year.to_i > if (year_int > 0) && (month_int > 0) && (month_int < 13) && > (day_int > 0)&& (day_int < 32) > if (self.year_int < 100) > �...@compare = Date.new(2000+self.year_int,self.month_int, > self.day_int) > if (@compare > Date.today) > self.year_int = 1900+self.year_int > else > self.year_int = 2000+self.year_int > end > self.year = self.year_int.to_s > end > self.birthday = Date.new(self.year_int, self.month_int, > self.day_int) > else > errors.add("Date") > end > debugger > end > > validates_inclusion_of :month_int, :in => 1..12, > :message => "should be between 1 and 12" > validates_inclusion_of :day_int, :in => 1..31, > :message => "should be between 1 and 31" > validates_numericality_of :year_int > validates_inclusion_of :sex, :in => %w{ M F }, > :message => "should be 'M' or 'm' or 'F' or 'f'" > validates_presence_of :sex, :month, :day, :year > validates_date :birthday, :before => Date.today+1, :after => 'Jan 1 > 1900', :before_message => 'Needs to be today or > before.', :after_message => 'Needs to be after 1/1/1900.' > > > end > > > since I added the code that changes a model variable, I get 2 > breakpoints from the 2 changes. This is not needed by my app and > causes a breakpoint that my user won't know how to bypass. Please help > with removing this issue. I assume rails is error-checking my code and > having a fit about not telling the views that a field has changed.. I am confused about exactly what is the problem that you are having. Is it that the code is stopping at the debugger statement in your code? If so just remove the debugger statement. If this is not the problem please be more explicit about what is happening. Colin -- 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.
[Rails] Re: [Announce] Bond - A gem which autocompletes method arguments in rails console
cldwalker wrote: > Hi, > Announcing bond, a gem which enhances autocompletion in the rails > console by autocompleting method arguments. It comes with the ability > to autocomplete attribute/column names for any model's class methods > (i.e. create and new) and instance methods (i.e. update_attribute(s)). > It can also autocomplete options (hash keys) to class methods such > AR::Base.establish_connection, find, and all. Users can also define > their own argument autocompletions for any method. To see a screencast > of bond in action, see > http://tagaholic.me/2010/05/07/screencast-of-argument-autocompletion-for-methods-in-irb.html > (starting at 3:15 for rails examples). That is quite cool. Thanks for sharing! :) -- 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-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.
[Rails] any way to stop notify(method) in a model ?
I am adding a function to check for 2 digit dates and change them into 4 digit before a Date.new has time to choke on it. My model is : class Person < ActiveRecord::Base belongs_to :household def before_validation # debugger self.month_int = self.month.to_i self.day_int = self.day.to_i self.year_int = self.year.to_i if (year_int > 0) && (month_int > 0) && (month_int < 13) && (day_int > 0)&& (day_int < 32) if (self.year_int < 100) @compare = Date.new(2000+self.year_int,self.month_int, self.day_int) if (@compare > Date.today) self.year_int = 1900+self.year_int else self.year_int = 2000+self.year_int end self.year = self.year_int.to_s end self.birthday = Date.new(self.year_int, self.month_int, self.day_int) else errors.add("Date") end debugger end validates_inclusion_of :month_int, :in => 1..12, :message => "should be between 1 and 12" validates_inclusion_of :day_int, :in => 1..31, :message => "should be between 1 and 31" validates_numericality_of :year_int validates_inclusion_of :sex, :in => %w{ M F }, :message => "should be 'M' or 'm' or 'F' or 'f'" validates_presence_of :sex, :month, :day, :year validates_date :birthday, :before => Date.today+1, :after => 'Jan 1 1900', :before_message => 'Needs to be today or before.', :after_message => 'Needs to be after 1/1/1900.' end since I added the code that changes a model variable, I get 2 breakpoints from the 2 changes. This is not needed by my app and causes a breakpoint that my user won't know how to bypass. Please help with removing this issue. I assume rails is error-checking my code and having a fit about not telling the views that a field has changed.. Bob -- 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.
[Rails] Why does Object.const_defined?() returns false in this case?
Hi, thank you for reading my post. I'll shortly describe my problem. I want to probe if a class is defined, and if it is, I want to instantiate it. Let's assume, the class name is "DemandType" and it exists: Object.const_defined?("DemandType") => false Object.const_get("DemandType") => Class Why does const_defined?() returns false in this case? I have also tested it in rails console, but it was not successful. I could also work with const_get() alone and catch the NameError exception, but I would really like to know why const_defined?() is not working. Thank you very much in advance! ms -- 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.
Re: [Rails] Re: Find ALL and then count them up?
On 11 May 2010 21:11, David Zhu wrote: > about not top posting, is this top posting? No. But it wasn't at the appropriate place in text. Making people scroll through pages of footers to get to your question won't incline them to answer you in future... just a thought. -- 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.
Re: [Rails] Re: Find ALL and then count them up?
[long post intentionally not snipped so the comments at the end make sense] On 11 May 2010 21:11, David Zhu wrote: > > > On May 11, 9:32 am, Colin Law wrote: >> On 11 May 2010 13:43, David Zhu wrote: >> >> > i need a join table? is the join table my comments table? >> >> It already is a join table, you just need to tell rails that it can >> use it as such. >> >> By the way could you not top post (so insert your comments at the >> appropriate point in the email you are replying to instead, as I have >> done here)? It makes it easier to follow the thread. For example >> your mail just says "I need a join table? .." but it is not at all >> clear what this is in reply to. >> >> Thanks >> >> Colin >> >> >> >> >> >> > On May 11, 8:36 am, Colin Law wrote: >> >> On 11 May 2010 13:32, David Zhu wrote: >> >> >> > Oh ok thanks! >> >> >> > But just to make sure we are on the same page- >> >> >> > Page has many comments >> >> > Comments has many Davids >> >> >> I believe that if you also say Page has_many davids through comments >> >> then you can get at all the davids for a post by >> >> @post.davids >> >> and hence you can use @posts.davids.count >> >> >> Colin >> >> >> > Would >> >> >> > @davidcount = Post.comments.map {|comment| comment.davids.count}.sum >> >> >> > find out how many David's are in a certain Post? >> >> >> > Just to clarify, im not trying to find All of the David's that exsit >> >> > in the entire database, just the amount of Davids that belongs to the >> >> > post. But the part i dont understand is how to count up the David's >> >> > that belongs to that Post, because there are comments in between. >> >> > (post has many comments, comments has many davids) And i want to find >> >> > out for a certain post (@post) how many davds belongs to it) >> >> >> > So would @davidcount = Post.comments.map {|comment| >> >> > comment.davids.count}.sum work for something like that? >> >> >> > Thank 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-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.-Hide quoted text >> >> - >> >> >> - Show quoted text - >> >> > -- >> > 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. > > > Ok Colin, > > about not top posting, is this top posting? No, it is bottom posting, which in this case is not much better. This can be seen from the fact that you had to preface your text with "about top posting", and that it is preceded by a large amount of irrelevant text. Had your reply read as follows it would be even clearer: On May 11, 9:32 am, Colin Law wrote: > On 11 May 2010 13:43, David Zhu wrote: > [snip] > > By the way could you not top post (so insert your comments at the > appropriate point in the email you are replying to instead, as I have > done here)? It makes it easier to follow the thread. For example > your mail just says "I need a join table? .." but it is not at all > clear what this is in reply to. Ok Colin, Is this top posting? -- 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.
Re: [Rails] If controller doesn't exist: search database for its name
On 11 May 2010 21:03, sso wrote: > if somebody enters a a controller that doesn't exist a database search > runs and looks for the controller name > > Is this possible without violating any "rules"? You would probably be able to do something by catching 404 errors in your application controller and then punting them off to a method that tries to guess what the user meant. Google for "Rails 404" for a few methods to try. -- 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.
[Rails] Re: Find ALL and then count them up?
On May 11, 9:32 am, Colin Law wrote: > On 11 May 2010 13:43, David Zhu wrote: > > > i need a join table? is the join table my comments table? > > It already is a join table, you just need to tell rails that it can > use it as such. > > By the way could you not top post (so insert your comments at the > appropriate point in the email you are replying to instead, as I have > done here)? It makes it easier to follow the thread. For example > your mail just says "I need a join table? .." but it is not at all > clear what this is in reply to. > > Thanks > > Colin > > > > > > > On May 11, 8:36 am, Colin Law wrote: > >> On 11 May 2010 13:32, David Zhu wrote: > > >> > Oh ok thanks! > > >> > But just to make sure we are on the same page- > > >> > Page has many comments > >> > Comments has many Davids > > >> I believe that if you also say Page has_many davids through comments > >> then you can get at all the davids for a post by > >> @post.davids > >> and hence you can use @posts.davids.count > > >> Colin > > >> > Would > > >> > @davidcount = Post.comments.map {|comment| comment.davids.count}.sum > > >> > find out how many David's are in a certain Post? > > >> > Just to clarify, im not trying to find All of the David's that exsit > >> > in the entire database, just the amount of Davids that belongs to the > >> > post. But the part i dont understand is how to count up the David's > >> > that belongs to that Post, because there are comments in between. > >> > (post has many comments, comments has many davids) And i want to find > >> > out for a certain post (@post) how many davds belongs to it) > > >> > So would @davidcount = Post.comments.map {|comment| > >> > comment.davids.count}.sum work for something like that? > > >> > Thank 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-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.-Hide quoted text - > > >> - Show quoted text - > > > -- > > 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. Ok Colin, about not top posting, is this top posting? -- 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.
[Rails] If controller doesn't exist: search database for its name
I'll use my recipe example again. It would be nice if I could have my routes (I think) set up so that if somebody enters a a controller that doesn't exist a database search runs and looks for the controller name as one of the categories (for example the user enters http://www.com/italian). This is an existing category in the database so it would likely then redirect to www.com/categories/italian (and from there the categories controller would handle things). Is this possible without violating any "rules"? -- 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.
[Rails] JOBS: Principal Ruby on Rails Software Developer (Boston - relocation assistance provided)
PLEASE SUBMIT RESUMES TO THE FOLLOWING LINK: http://hire.jobvite.com/j/?aj=o1HiVfwF&s=googlekeywords Brief Description Does the idea of working in a start-up environment where you have a significant role in defining and creating the product get you excited? We’ve got some big product ideas that will have an impact on millions of people and are looking for the right people to help us build them. We’re looking for passionate engineers that love solving large, hard scaling problems and appreciate beautiful UIs. Description This position is located in Cambridge, MA and relocation to that area will be necesarry. Relocation assistance is available for those individuals that will require it. Summary - Principal Ruby Rails Software Engineer You will be joining a team of technical and business veterans whose collective experience includes writing J2EE servers, launching the Flash platform and growing successful, public companies. We look forward to learning as much from you as you will learn from us. Working for Brightcove will give you a unique opportunity to join a growing, privately held company, and play an integral role building products and online services that promise to transform the media industry and change the way people all over the world watch video. Responsibilities - Principal Ruby Rails Software Engineer: Develop subsystems that are scalable, maintainable and debuggable. Participate actively in software design discussions. Participate actively in product definition discussions. Writing code that is both functional and elegant. Design and implement unit tests. Diagnose performance bottlenecks and implement optimizations. Minimum Job Requirements: Excellent knowledge of Ruby, Rails and JRuby In-depth experience building distributed, multithreaded, scalable, fault-tolerant systems Excellent knowledge of Web service technologies (HTTP, AJAX, REST, SOAP) Solid coding practices including design, unit testing, and peer code- reviews 5 to 7+ years of development experience Strong knowledge of Java Excellent technical communication skills in both written and spoken English Why Brightcove? Brightcove is an online video platform that is used by media companies, businesses and organizations worldwide to publish and distribute video on the Web. We've worked hard to create a company where talented, passionate people can thrive in a culture that values individual empowerment, excellence and collaboration. Working at Brightcove gives you the chance to reshape how media is published and consumed while you develop your skills, grow your career, and have fun. We look forward to receiving your application! Brightcove is an Equal Opportunity Employer (EOE). -- 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.
Re: [Rails] how to redirect
On 11 May 2010 16:48, tom wrote: > hi, > > i have a "notes" model which i include in various other views via > partial. how can i tell / what do i need to do in order to redirect the > user back to the view where he was instead to the index-view of the > notes? Have a look at the docs for redirect_to and you will see that there is a :back option to go back to where you were. Colin -- 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.
[Rails] [JOBS] Agile Rails job in Oceanside CA (w/plans to move to Orange County in the near future)
You: * Programmer * Loves to code. Creating and building stuff excites you * Knows OO Uncle Bob's SOLID, the principles of design patterns rather than rubber stamped templates * Appreciate elegance, to include Kent Beck's rules of simple design * Works efficiently and effectively, striving to always get better and lean * Team player * Has fun, is fun * Polyglot, but loves Ruby * Web programming, but it's not all you've done or will do * Have ideas, willing to pitch and see them come to fruition Us: * We publish the best financial research in the world, including real time commentary and trading recommendations. Hedgeye Risk Management is the leading real-time research firm. The Hedgeye team features some of the world’s most regarded research analysts – united around a vision of independent, un-compromised real-time investment research as a service. Hedgeye is taking the processes of a world-class investment team and ripping back the curtain on Wall Street, by making the real- time insights the bankers have jealously guarded available to every individual. * Startup that actually makes money * Our web application is the distribution part of our business, not the only part of the business * Do Agile development with a small team, with company buy in * Developer and Business work together directly Things that excite you * Agile - the more eXtreme the better * Web development, esp. Ruby on Rails, the Rails/Merb 3.0 merge excites you * TDD/BDD - nuff said, you believe this to be the most effective way to develop * Refactoring - without quality, code is nothing * Pair Programming - quality, sharing, synergy are important to you * Exploring new tech - you know that somewhere someone's writing the new hotness and you'd like to be in on it Skills you ought to have * Ruby - this is what we code most of our stuff in * TDD/BDD - this is how we work * Rspec, Cucumber - these are our main automated testing frameworks * *nix savvy - we develop on OSX, deploy to linux * Verbal/written communication skills - everyone asks for these, we'll be lemmings on this one Bonus points * scaled a web application - the bigger the better * security - extra points here Do we have a match? Attention Jr. programmers. If you don't match this yet but aspire to such, we may have an opening for you! Salary Commensurate with Ability Office is in Oceanside, CA, with plans to more north to Orange County in the near future. Please reply to this posting with your resume and cover letter to fch...@hedgeye.com Principals only. Recruiters, please don't contact this job poster. Please, no phone calls about this job! Please do not contact job poster about other services, products or commercial interests. -- 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.
[Rails] Re: Validating User
google rails LDAP authentication -- 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-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.
[Rails] Validating User
Hi people, I need to know, if is possible validate a user from windows network with rails, like a intranet. graciously, Leonardo -- 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.
[Rails] Re: sqlite3-ruby-1.2.5 is cached?
Mike wrote: > Are you running Snow Leopard? > > If so, maybe dig into some of the comments here: > > http://stackoverflow.com/questions/1350359/snow-leopard-ruby-on-rails-sqlite3-issue Thanks Mike! This article resolved my 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-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.
[Rails] different ruby versions...different results
i just got a new mbp and started transferring some projects over. when starting to use geokit on it, geocode_ip_address worked but not on the imac. differences are imac is running ruby 1.9.1p376 and mbp is running ruby 1.8.7. is there something in that difference that would cause geocode ip address not to work on imac? now that i see this working on the mbp, im concerned it will stop working once i upgrade to 1.9.1. it seems to be a to_yaml conversion for the cookie thats causing the error. id be curios to install 1.9.1 on the mbp if i could control which version of ruby to use. im kinda new at the whole ruby rails thing and unsure of how to load and use different versions. any suggestions? -- 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.
[Rails] Re: Reject a nested object if all parameters of its own nested object are blank
oh, it works if you reject the creation of the third-level nested model in the second-level nested model. On May 7, 4:46 pm, Fattah wrote: > You can write method to validate nested result attributes. > > Def valid_nested_results?(results_attributes) > > results_attributes.each do|res_attr| > return false if(res_attr['attr1'].blank? and res_attr['attr2'].blank? ) > end > > return true > > end > > And use this method in reject_if instead of > attributes['results_attributes'].blank? > > Or you can also define the appropriate :reject_if for nested attribute > definition for results in treatment model. > > Does it help? > > -Original Message- > From: Mlle > Sent: Friday, 7 May 2010 7:35 PM > To: Ruby on Rails: Talk > Subject: [Rails] Reject a nested object if all parameters of its own nested > object are blank > > Hello, > > I have a model called Sample that has many Treatments. A Treatment > can have many Results. > > I want to reject the creation of a Treatment if all its fields are > blank and if all the fields of each of its nested Results are blank. > > I have this in the Sample model: > > accepts_nested_attributes_for :treatments, :allow_destroy => > true, :reject_if => proc { |attributes| > attributes['treatmenttype'].blank? && attributes['author'].blank? && > attributes['results_attributes'].blank? } > > This part: > attributes['results_attributes'].blank? > > only makes it reject the Treatment if there are no Results, but how > can I write the conditions so that it will reject the creation of a > Treatment if all the attirubtes of each Result are blank? Right now > it creates the Treatment if the Result exists, regardless of whether > all its fields are blank. > > -- > 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.
[Rails] Inserted html using javascript function
I'm using a javascript function to insert html code into my page (following the Railscast on nested models) The function that inserts the javascript is this: function add_result(link, association, content) { var new_id = new Date().getTime(); var regexp = new RegExp("new_" + association, "g"); var linkrow = $(link).up("tr"); linkrow.insert({ after: content.replace(regexp, new_id) }); } And this is the html.erb that is inserted: <% for c in @picture_fields %> <% if c == "intervention" %> <%=t 'form.results.picture.'+c%> <%= f.radio_button c, t('form.results.picture.interventionoptions.option1')%><%=t 'form.results.picture.interventionoptions.option1'%><%= f.radio_button c, t('form.results.picture.interventionoptions.option2')%><%=t 'form.results.picture.interventionoptions.option2'%><%= f.radio_button c, t('form.results.picture.interventionoptions.option3')%><%=t 'form.results.picture.interventionoptions.option3'%> <% elsif c == "couchetype" %> <%=t 'form.results.picture.'+c%> <%= f.text_field :selected_couchetypes, :readonly=>true %> <%= link_to( image_tag('more.png', :border=>0, :id=>"new_results_pictures_results_pictures_couchetype"), {:controller=>"thesaurus", :action=>"list", :id=>"new_results_pictures_results_pictures_couchetype"}, { :popup=>['thesaurus', 'height=800,width=750,location=no,scrollbars=yes']}) %> <%else %> <%=t 'form.results.picture.'+c%> <%= f.text_field c, :class=>"number"%> <% end %> <% end %> <%= f.hidden_field :_destroy %><%= link_to_function t('form.results.picture.destroy'), "remove_fields(this, '.pictureclass')"%> When the html is inserted, there is a size="30" attribute for the text input field: But I have no idea how it got there. Any ideas? -- 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.
[Rails] Re: hostingrails.com appears to have had an ownership change
I would support anyone who has had a similar experience with Hostingrails (which seems like many), to pursue a class action lawsuit. Our story: My company is a web agency and we hosted several of our client websites with Hostingrails. On April 30th, I received notification from one of our customers that their site was down. I then found out all of our sites were down. We called hostingrails support and submitted a ticket for an urgent correction. No response was officially given until Sunday morning! We were not able to call on the weekend as they have NO weekend call support. After our own developer's investigation, we finally realized that our sites IP addresses had been changed (without them even informing us!). After posting numerous tickets, hostingrails finally gave us the new IP's to redirect to. This was only the start of our problems...On Monday, we called the support and they finally explained there was a server upgrade and "we should have know about this" (our sites have been down for 72 hours at this point). We NEVER received any email or notification, nor could they prove they sent us any such message. I demanded to speak to a manager in charge, his name is Derek Hopper. He wasn't available but support promised to call back taking my number (European number). Then he sent an email saying he was unable to make international calls (what a load of BS!). In short, we never got our issues resolved and the server change forced us to move all websites to a new server. This wasted 5 days of our time and not to mention significant financial losses and damage to our reputation. Even after all of this, we asked Derek for our money back on hosting we have not used (we paid 2 years in advance hosting). He came up with the biggest BS excuse ever saying he "can't make a refund due to the merchant system". He then asked us to "trust him" and we could have free hosting for 2 years (extended to 2014). He even had the nerve to offer this when our current issues were still NOT resolved. I have never dealt with more incompetent people in my life. We have not received a refund yet but will do whatever it takes to get some justice in this case. If anyone else has a similar story to share or would like to investigate a class action lawsuit, please email me at clint.hai...@gmail.com Clinton On May 9, 7:46 pm, Rick wrote: > The original estimate of 24-72 hours is currently off by over a week. > > I currently experience site halts of over 5 minutes more than twice > daily. > > My git repository suddenly reverted to the first commit. I had to > rebuild my development history from a git clone. Fortunately all > history was present in the clone so no work was lost. > > I'm not sure who the "my" is in the new name "my.hostingrails.com" but > it definitely doesn't seem to be paying customers. > > This feels like a class action suit in the making... > > Rick > > On May 9, 11:03 am, Marnen Laibow-Koser wrote: > > > > > > > gogo wrote: > > > Hi, I pretty much had the same issues reported here, especially after > > > the "upgrade" on some servers. > > > > The question is: what RoR hosting provider would you suggest ? I've > > > heard good things about site5, and was myself a happy Lunarpages > > > customer but I left because at the time they were not supporting RoR > > > and shell access. > > > I like Slicehost, or Heroku. > > > > thanks > > > > -ugo- > > > Best, > > -- > > Marnen Laibow-Koserhttp://www.marnen.org > > mar...@marnen.org > > -- > > Posted viahttp://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-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.
[Rails] Memcached and Rails 3
I am porting a v2 app to v3 and hitting an issue with configuring memcached as the cache store via: config.cache_store = :mem_cache_store, Memcached::Rails.new In the new version this generates: /Users/neil/code/gli/config/environments/development.rb:20:in `block in ': uninitialized constant Gli::Application::Memcached (NameError) I have memcached in my Gemfile Does anyone know how to correctly configure this? -- 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.
[Rails] has_one/belongs_to -- accessing the subordinate
With a has_one/belongs_to relationship, what's the best way to guarantee that the belongs_to object gets created and is accessible alongside the has_one object? I *think* the after_create callback is a good choice, but I discovered an oddity while trying it. F'rinstance, if every horse has a carriage: ActiveRecord::Schema.define do create_table(:horses) {|t| t.timestamps } create_table(:carriages) {|t| t.timestamps; t.integer :horse_id } end class Horse < ActiveRecord::Base after_create :create_carriage has_one :carriage, :dependent => :destroy private def create_carriage Carriage.create(:horse => self) end end class Carriage < ActiveRecord::Base belongs_to :horse end This works fine using create: >> horse1 = Horse.create() => # >> horse1.carriage => # It also works if you call Horse.new(), horse.save!() and *then* horse.carriage(): >> seabiscuit = Horse.new() => # >> seabiscuit.save! => true >> seabiscuit.carriage => # If you call horse.carriage *before* horse.save!(), it shows up as nil -- that's to be expected since there's nothing in the db to associate with. But if you THEN call horse.save! followed by horse.carriage, it STILL reports nil: >> nellie = Horse.new => # >> nellie.carriage => nil # no carriage because we haven't called save! yet >> nellie.save! => true >> nellie.carriage => nil # whoa, nellie! where's your carriage??? ... despite this, a carriage really was created for nellie: >> nellie => # >> Carriage.find_by_horse_id(nellie.id) => # I can imagine why this is happening: Calling horse.carriage caches a value and doesn't bother to re-check the database after the save!. Since I'm *sure* it's not a bug ;), I must be doing something improper. How would a seasoned expert explain this? (And is it documented somewhere?) Thanks. - ff -- 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-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.
[Rails] Re: Changing link_to link location slightly..
THANK YOU SO MUCH! On May 11, 4:54 pm, Ar Chron wrote: > map.resources :tutorials, > :controller => "categories" > :path_prefix => "/category/:category_id", > > There should be a comma at the end of the second line after > "categories", my bad. > -- > Posted viahttp://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-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.
[Rails] Re: Which linux distro for rails using ruby 1.9.1
@Kevin Monceaux Thanks a lot, I've never tried openSuse nor rvm, after your reply I got interested on rvm and I'm reading on it right now. Thanks again, I hope to get another response. -- 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-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.
[Rails] Re: Changing link_to link location slightly..
map.resources :tutorials, :controller => "categories" :path_prefix => "/category/:category_id", There should be a comma at the end of the second line after "categories", my bad. -- 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-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.
[Rails] how to redirect
hi, i have a "notes" model which i include in various other views via partial. how can i tell / what do i need to do in order to redirect the user back to the view where he was instead to the index-view of the notes? thx -- 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.
[Rails] Re: sqlite3-ruby-1.2.5 is cached?
Are you running Snow Leopard? If so, maybe dig into some of the comments here: http://stackoverflow.com/questions/1350359/snow-leopard-ruby-on-rails-sqlite3-issue On May 11, 11:34 am, John John wrote: > @mike I tried (sudo gem install sqlite3-ruby) but I'm still getting > header file issues? -- 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.
[Rails] Re: sqlite3-ruby-1.2.5 is cached?
@mike I tried (sudo gem install sqlite3-ruby) but I'm still getting header file issues? -- 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-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.
Re: [Rails] can access the through attributes from the many with has_many through?
On 11 May 2010 16:05, dino d. wrote: > hi - > > if i have > > A has_many B > A has_many C through B > > Is there any way to retrieve the B attributes once I have a C object? Assuming that you also have B has_many C C belongs_to B then if you have a C in @c you can say @c.b Colin > > For example: > > class User < ... > > has_many :friend_links > has_many :friends, :through => :friend_links, :class => User > ... > > friends = user.friends > for f in friends > link = f.friend_link #i want to get the through object because i > store some metrics here > > is this possible? i realize i can just ignore the through and just > grab the friend_links directly, but i have various types of friends, > some are borne of friend_links, others have a different genesis, and > i'd like to just treat them in one fell swoop, and if one of them > happens to be born of a through, i'll do one thing, but otherwise, > i'll do something else. > > thanks for any help, > dino > > -- > 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. > > -- 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.
Re: [Rails] Reading an API Server Response
On Tue, May 11, 2010 at 7:00 AM, Mindtonic wrote: > I am trying to debug an API. Towards the end of the process, the > remote server sends me a request. I respond to that request with: > render :text => my_response, :status => 200. I am trying to find out > how to read the remote server's response. > > So basically this is a three part cycle. How do I access the third > part? > > 1. Remote Server sends a request > 2. I respond with text and a status of 200 > 3. Remote Server responds with the results of the transaction. There's no such thing as a response to a response. #3 would be a second request, assuming that the remote server is programmed to initiate one. And in that case, presumably you'll know what URL it's requesting, right? -- Hassan Schroeder hassan.schroe...@gmail.com twitter: @hassan -- 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.
[Rails] can access the through attributes from the many with has_many through?
hi - if i have A has_many B A has_many C through B Is there any way to retrieve the B attributes once I have a C object? For example: class User < ... has_many :friend_links has_many :friends, :through => :friend_links, :class => User ... friends = user.friends for f in friends link = f.friend_link #i want to get the through object because i store some metrics here is this possible? i realize i can just ignore the through and just grab the friend_links directly, but i have various types of friends, some are borne of friend_links, others have a different genesis, and i'd like to just treat them in one fell swoop, and if one of them happens to be born of a through, i'll do one thing, but otherwise, i'll do something else. thanks for any help, dino -- 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.
[Rails] Re: sqlite3-ruby-1.2.5 is cached?
It appears it isn't finding the header file it's looking for. If your system's configured like mine you'll find it elsewhere. I think if you skip all that and just (remote) install the gem sqlite3- ruby you should be good to go. -- 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.
[Rails] Gem::Dependency#version_requirements is deprecated...
Seen when running scripts/console, Ruby version not important. What is this telling me? Loading development environment (Rails 2.3.5) /opt/local/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/rails/ gem_dependency.rb:119:Warning: Gem::Dependency#version_requirements is deprecated and will be removed on or after August 2010. Use #requirement Checking gem_dependency.rb shows: 118:def requirement 119: r = version_requirements 120: (r == Gem::Requirement.default) ? nil : r 121:end which function, if commented out, shuts off the warning. Of course, replacing "version_requirements" with "requirement" produces the expected recursive stack level error. Any thoughts? Rick -- 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.
[Rails] sqlite3-ruby-1.2.5 is cached?
I had Rails --version 3.0.0.beta3 installed. When I try to start the server I get a message, "sqlite3-ruby-1.2.5 is cached, but not installed. Try running 'bundle install'. When I run the bundle install the following message below appears: ### Installing sqlite3-ruby (1.2.5) from .gem files at /Users/john.ranaudo/.bundle/ruby/1.8/cache with native extensions /Library/Ruby/Site/1.8/rubygems/installer.rb:482:in `build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::ExtensionBuildError) /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby extconf.rb mkmf.rb can't find header files for ruby at /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/ruby.h Gem files will remain installed in /Users/john.ranaudo/.bundle/ruby/1.8/gems/sqlite3-ruby-1.2.5 for inspection. Results logged to /Users/john.ranaudo/.bundle/ruby/1.8/gems/sqlite3-ruby-1.2.5/ext/sqlite3_api/gem_make.out ### Any thoughts on how to resolve this? Thanks, John -- 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-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.
[Rails] Reading an API Server Response
Hello, I am trying to debug an API. Towards the end of the process, the remote server sends me a request. I respond to that request with: render :text => my_response, :status => 200. I am trying to find out how to read the remote server's response. So basically this is a three part cycle. How do I access the third part? 1. Remote Server sends a request 2. I respond with text and a status of 200 3. Remote Server responds with the results of the transaction. How do I access this third response? I specifically would like to log the body of the response so that I can read it and figure out what is going on through the api calls. Any help or direction would be greatly appreciated. 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-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.
Re: [Rails] Re: Find ALL and then count them up?
On 11 May 2010 13:43, David Zhu wrote: > i need a join table? is the join table my comments table? It already is a join table, you just need to tell rails that it can use it as such. By the way could you not top post (so insert your comments at the appropriate point in the email you are replying to instead, as I have done here)? It makes it easier to follow the thread. For example your mail just says "I need a join table? .." but it is not at all clear what this is in reply to. Thanks Colin > > On May 11, 8:36 am, Colin Law wrote: >> On 11 May 2010 13:32, David Zhu wrote: >> >> > Oh ok thanks! >> >> > But just to make sure we are on the same page- >> >> > Page has many comments >> > Comments has many Davids >> >> I believe that if you also say Page has_many davids through comments >> then you can get at all the davids for a post by >> @post.davids >> and hence you can use @posts.davids.count >> >> Colin >> >> >> >> >> >> >> >> > Would >> >> > @davidcount = Post.comments.map {|comment| comment.davids.count}.sum >> >> > find out how many David's are in a certain Post? >> >> > Just to clarify, im not trying to find All of the David's that exsit >> > in the entire database, just the amount of Davids that belongs to the >> > post. But the part i dont understand is how to count up the David's >> > that belongs to that Post, because there are comments in between. >> > (post has many comments, comments has many davids) And i want to find >> > out for a certain post (@post) how many davds belongs to it) >> >> > So would @davidcount = Post.comments.map {|comment| >> > comment.davids.count}.sum work for something like that? >> >> > Thank 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-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.- Hide quoted text - >> >> - Show quoted text - > > -- > 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. > > -- 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.
Re: [Rails] Re: Find ALL and then count them up?
On Tue, May 11, 2010 at 8:43 AM, David Zhu wrote: > On May 11, 8:36 am, Colin Law wrote: >> I believe that if you also say Page has_many davids through comments >> then you can get at all the davids for a post by >> @post.davids >> and hence you can use @posts.davids.count > i need a join table? is the join table my comments table? Yes but.. First I notice that you continue to use code of the form Post.comments. Which won't work, since the associations like belongs_to, has_many ... create INSTANCE rather than class methods. You need to use something like some_post.comments. .. where some_post refers to a particular instance of Post. Second, I suspect that David here is a hypothetical model class, and that what you might really be trying to do is count all the comments made by a particular user. Maybe you want something like: class Post < ActiveRecord::Base has_many :comments end class User < ActiveRecord::Base end class Comment < ActiveRecord::Base belongs_to :post belongs_to : user named_scope :by_user, lambda {|user| :conditions => {:user => user} end then some_post = Post.find(params[:id]) # or some other code to get a particular post david = User.find_by_userid("david") # or some other code to get a particular user some_post.comments.by_user(david).count -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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.
Re: [Rails] Which linux distro for rails using ruby 1.9.1
Japmsn, On Tue, May 11, 2010 at 06:27:05AM +0200, Japmsn Japms wrote: > Question: > If you currently have rails installed from gems and working with ruby > 1.9.1 , which distro are you using? I hadn't tried that particular version yet. But, it gave me an excuse to experiment more with rvm, which I'm quickly becoming addicted to. I installed ruby 1.9.1 via rvm, then performed a gem install rails. I took a couple of test projects for a spin and all appears well. Well, with one of the projects which had paperclip installed I had to change the case statement syntax in vendor/plugins/paperclip/lib/paperclip/storage.rb to use the 1.9.x syntax. But, other than that all appears well. I'm running OpenSuSE this week. -- Kevin http://www.RawFedDogs.net http://www.WacoAgilityGroup.org Bruceville, TX What's the definition of a legacy system? One that works! Si hoc legere scis nimium eruditionis habes. Longum iter est per praecepta, breve et efficax per exempla!!! -- 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.
[Rails] Re: Bundler for Rails 3 Engine
> > How do I configure a Rails-3 Engine so that the engine's Gemfile is > > integrated with the parent-Rails-app's bundle? > > You package your plugin as a gem, then add it as a dependency to your Rails > app. > > Write up a yourplugin.gemspec and put gem 'yourplugin', :path => > '/to/your/plugin' in your app try. Hi Jeremy, I'm not sure you answered the OP's question (as I'm looking for the same answer). He wants to know, if he has a Gemfile within his gem/ engine how can he get the Rails app/Bundler to automatically load it's dependencies along with the Rails app's hardcoded dependencies. For example, if you create your own Rails 3 Engine gem called MyShop and MyShop has a dependency on ActiveMerchant, he wants to put that dependency in a Gemfile within MyShop and not within the Rails app itself. I agree with this (your Rails app shouldn't need to know what the dependencies are for the dependencies you have, Bundler should just take care of them) and I'm trying to do the same thing. Cheers, Andy -- 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.
[Rails] Re: Find ALL and then count them up?
i need a join table? is the join table my comments table? On May 11, 8:36 am, Colin Law wrote: > On 11 May 2010 13:32, David Zhu wrote: > > > Oh ok thanks! > > > But just to make sure we are on the same page- > > > Page has many comments > > Comments has many Davids > > I believe that if you also say Page has_many davids through comments > then you can get at all the davids for a post by > @post.davids > and hence you can use @posts.davids.count > > Colin > > > > > > > > > Would > > > @davidcount = Post.comments.map {|comment| comment.davids.count}.sum > > > find out how many David's are in a certain Post? > > > Just to clarify, im not trying to find All of the David's that exsit > > in the entire database, just the amount of Davids that belongs to the > > post. But the part i dont understand is how to count up the David's > > that belongs to that Post, because there are comments in between. > > (post has many comments, comments has many davids) And i want to find > > out for a certain post (@post) how many davds belongs to it) > > > So would @davidcount = Post.comments.map {|comment| > > comment.davids.count}.sum work for something like that? > > > Thank 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-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.- Hide quoted text - > > - Show quoted text - -- 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.
Re: [Rails] Re: Find ALL and then count them up?
On 11 May 2010 13:32, David Zhu wrote: > Oh ok thanks! > > But just to make sure we are on the same page- > > Page has many comments > Comments has many Davids I believe that if you also say Page has_many davids through comments then you can get at all the davids for a post by @post.davids and hence you can use @posts.davids.count Colin > > Would > > @davidcount = Post.comments.map {|comment| comment.davids.count}.sum > > find out how many David's are in a certain Post? > > Just to clarify, im not trying to find All of the David's that exsit > in the entire database, just the amount of Davids that belongs to the > post. But the part i dont understand is how to count up the David's > that belongs to that Post, because there are comments in between. > (post has many comments, comments has many davids) And i want to find > out for a certain post (@post) how many davds belongs to it) > > So would @davidcount = Post.comments.map {|comment| > comment.davids.count}.sum work for something like that? > > > Thank 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-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. > > -- 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.
[Rails] Re: Find ALL and then count them up?
Oh ok thanks! But just to make sure we are on the same page- Page has many comments Comments has many Davids Would @davidcount = Post.comments.map {|comment| comment.davids.count}.sum find out how many David's are in a certain Post? Just to clarify, im not trying to find All of the David's that exsit in the entire database, just the amount of Davids that belongs to the post. But the part i dont understand is how to count up the David's that belongs to that Post, because there are comments in between. (post has many comments, comments has many davids) And i want to find out for a certain post (@post) how many davds belongs to it) So would @davidcount = Post.comments.map {|comment| comment.davids.count}.sum work for something like that? Thank 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-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.
Re: [Rails] Re: Find ALL and then count them up?
On May 11, 2010, at 7:47 AM, David Zhu wrote: Thank you, I swear this is the last question about this- Is there a way to go one level deeper, so instead of @totalcount = Post.comments.count, could I have lets say... --- @totalcount = Post.comments.davids.count, if comments has many davids? a Comment might have many davids, but you have comments. So basically instead of just post has many comments, i also want to add comments has many davids, and then find out how many davids are in the Post. so for each comment, you want the davids, and count up the total So whats the syntax for that? DOes that make sense? How could I do something like that? Thanks :) @davidcount = Post.comments.map {|comment| comment.davids.count}.sum But it might be more efficient to say something like: @davidcount = David.count depending on what you really want to know. -Rob Rob Biedenharn http://agileconsultingllc.com r...@agileconsultingllc.com http://gaslightsoftware.com r...@gaslightsoftware.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-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.
[Rails] Re: Find ALL and then count them up?
Thank you, I swear this is the last question about this- Is there a way to go one level deeper, so instead of @totalcount = Post.comments.count, could I have lets say... --- @totalcount = Post.comments.davids.count, if comments has many davids? So basically instead of just post has many comments, i also want to add comments has many davids, and then find out how many davids are in the Post. So whats the syntax for that? DOes that make sense? How could I do something like that? 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-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.
Re: [Rails] moving to Montana (any rails people live in Montana?)
Yep, there are a few of us here...but it's a big land mass. :) Which part are you headed to? (Feel free to mail off the list if you'd like) Larry On Tue, May 11, 2010 at 12:09 AM, internetchris wrote: > Hey Group, > > Montana can be a dry and weary land when it comes to developers. I'm > wondering if there are any Ruby or Rails developers in the state? I'm > currently in Utah, but moving at the end of the month. I would love to > connect with some like minded developers if they exist. > > Thanks! > > Chris > > -- > 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. > > -- 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.
Re: [Rails] Getting data from an ancestor (I think)
On Tue, May 11, 2010 at 5:00 AM, Colin Law wrote: > On 10 May 2010 21:56, sso wrote: >> I'm setting up a music catalogue to learn my way around RoR. In >> index.html.erb I would like to show the band name instead of the id. >> What is the proper way to do this? >> >> # records.rb > > That should be record.rb, not records > >> class Record < ActiveRecord::Base >> belongs_to :band; >> end >> >> # bands.rb > > Again, should be singular > >> class Band < ActiveRecord::Base >> has_many :records >> end >> >> # views/records/index.html.erb >> ... >> <% @records.each do |record| %> >> >> <%=h record.band.name %> > > That should work, assuming you change the filenames above. Watch out > for the case where no band has been allocated, however, ie record.band > is nil > Which is one reason that I'd recommend not having the view reach through one model to get to the attributes of another, a violation of the "law" of demeter (which I personally call the "strong suggestion" of demeter. So I'd do something like: in the view ... <%=h record.artist %> and in the record model class Record < ActiveRecord::Base belongs_to band def artist if band band.name else "Anonymous" end end end This decouples the view from the DB representation, and will make changes down the road like changing the database schema to allow multiple artist compilations to be represented, when you will change the belongs_to and has_many relations in Record and Band to either has_and_belongs_to_many or has_many :through associations. -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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.
Re: [Rails] Re: Find ALL and then count them up?
On Mon, May 10, 2010 at 7:37 PM, David Zhu wrote: > Thanks guys, > > If I have nested associations, how could i count that? For ex- > > I want to do something like @totalcount = Post.comment.count , or > something like that > > How could i do that? ( i want to count the comments that belong to > that post) Assuming that Post has_many :comments, and you've gotten the particular post of interest to be referenced by the variable post. For the sake of the example below, let's say that the id of that post is 42 then either post.comments.count or post.comments.size will do a sql query like SELECT count(*) AS count_all FROM `users` WHERE (`users`.account_id = 42) and return the value of count_all HTH -- Rick DeNatale Blog: http://talklikeaduck.denhaven2.com/ Github: http://github.com/rubyredrick Twitter: @RickDeNatale WWR: http://www.workingwithrails.com/person/9021-rick-denatale LinkedIn: http://www.linkedin.com/in/rickdenatale -- 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.
[Rails] Treaceability Matrix
Hello Everyone, Can any suggest me use of traceability matrix in project management from QA point of view. Also it would be great, if i can have some sample/template on the same. Thanks & Regards Bhupendra -- 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-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.
[Rails] Re: any plugin/gem for charting?
Shameer Melethil wrote: > Hi All, > > Could anybody tell me about most popular stable plugins/gems for > charting in rails > OpenFlash Chart Gruff,ChartDirector -- 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-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.
Re: [Rails] any plugin/gem for charting?
not sure about any hem/plugin But i used Fusioncharts for preparing basic charts in my application. The free version covers the basic required charts. On Tue, May 11, 2010 at 10:20 AM, Shameer Melethil wrote: > Hi All, > > Could anybody tell me about most popular stable plugins/gems for > charting in rails > > > Thanks, > Shameer > -- > 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-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. > > -- 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.
Re: [Rails] Getting data from an ancestor (I think)
On 10 May 2010 21:56, sso wrote: > I'm setting up a music catalogue to learn my way around RoR. In > index.html.erb I would like to show the band name instead of the id. > What is the proper way to do this? > > # records.rb That should be record.rb, not records > class Record < ActiveRecord::Base > belongs_to :band; > end > > # bands.rb Again, should be singular > class Band < ActiveRecord::Base > has_many :records > end > > # views/records/index.html.erb > ... > <% @records.each do |record| %> > > <%=h record.band.name %> That should work, assuming you change the filenames above. Watch out for the case where no band has been allocated, however, ie record.band is nil Colin > <%=h record.title %> > <%=h record.description %> > ... -- 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.
[Rails] [Announce] Bond - A gem which autocompletes method arguments in rails console
Hi, Announcing bond, a gem which enhances autocompletion in the rails console by autocompleting method arguments. It comes with the ability to autocomplete attribute/column names for any model's class methods (i.e. create and new) and instance methods (i.e. update_attribute(s)). It can also autocomplete options (hash keys) to class methods such AR::Base.establish_connection, find, and all. Users can also define their own argument autocompletions for any method. To see a screencast of bond in action, see http://tagaholic.me/2010/05/07/screencast-of-argument-autocompletion-for-methods-in-irb.html (starting at 3:15 for rails examples). To install: gem install bond For more: * Source: http://github.com/cldwalker/bond * Docs: http://tagaholic.me/bond/doc/ * Homepage: http://tagaholic.me/bond/ Enjoy, Gabriel -- 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.
[Rails] Getting data from an ancestor (I think)
I'm setting up a music catalogue to learn my way around RoR. In index.html.erb I would like to show the band name instead of the id. What is the proper way to do this? # records.rb class Record < ActiveRecord::Base belongs_to :band; end # bands.rb class Band < ActiveRecord::Base has_many :records end # views/records/index.html.erb ... <% @records.each do |record| %> <%=h record.band.name %> <%=h record.title %> <%=h record.description %> ... -- 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.
[Rails] Re: has_many_polymorphs with searchlogic
I'm curious about this one also. If someone might take a look into this problem and associations created by has_many_polymorphs plugin it would be great. Martin On Mar 23, 11:14 pm, tispratik wrote: > Has anyone been able to use searchlogic with has_many_polymorphs? > Are they compatible? -- 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.