[Rails] Using gems within Engines - need to 'require'?

2012-10-24 Thread Rob Nichols
I'm building an engine and as part of that I want to use acts_as_list. So I've added 's.add_dependency acts_as_list' to my gemspec file. When I bundle acts_as_list gets installed as I would expect, and is listed by 'gem list' However, when I go to use acts_as_list in my model I get method not

[Rails] Re: Counting items in associate with a limit

2011-02-14 Thread Rob Nichols
I think I've found a workaround. category.articles.limit(3).count = 8 category.articles.find(:all, :limit = 3).count = 3 If I use the old Rails 2 methods, the system works correctly. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the

[Rails] Counting items in associate with a limit

2011-02-11 Thread Rob Nichols
Rails 3 --- I have a relationship where Category has_and_belongs_to_many Article. I want to grab a small subsection of articles related to a particular category. When I try to iterate over these, Rails tries to count the records and gets the wrong number. The issue is that there is bug in

[Rails] Re: Re: get last record before, or first record after, a given date?

2010-07-15 Thread Rob Nichols
Colin Law wrote: Is there any advantage to this rather than the original solution (now simplified by the realisation that the second query does not need the :conditions spec)? It is all done in one query, but both parts of the query will be executed even when the second part is not required,

[Rails] Re: About master page in Rubi on rails

2010-07-15 Thread Rob Nichols
Marnen Laibow-Koser wrote: No. NetBeans is a great IDE, but it does not work at all well with Rails IMHO. I know some people would disagree, Yup! Me to start with :0) I think it depends where you come from. I am sure that users who come from a Visual Studio environment would feel more at

[Rails] Re: How to do a case insensitive search with multiple elements?

2010-07-15 Thread Rob Nichols
Model.find_all_by_firstname(a.collect{|a| a.downcase}) -- 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

[Rails] Re: ActiveRecord::Observer, update_all and has_many

2010-07-15 Thread Rob Nichols
I've worked out a solution. It might not be the neatest, but it works for me: has_many has its own call backs. So I can trigger a logging activity using the 'after_remove' call back like this: has_many :users, :after_remove = :log_removal I am then able to grab the Observe object using

[Rails] Re: Re: How to do a case insensitive search with multiple elements?

2010-07-15 Thread Rob Nichols
Colin Law wrote: On 15 July 2010 09:05, Rob Nichols li...@ruby-forum.com wrote: Model.find_all_by_firstname(a.collect{|a| a.downcase}) Will that work if the names in the db include upper case chars? I think the compare in the find needs to be case insensitive rather than what is being

[Rails] Re: Re: Re: get last record before, or first record after, a given date?

2010-07-15 Thread Rob Nichols
Colin Law wrote: even better as named_scopes (and I think a typo on the names, they should be first_state, and last_state_before). Agreed on both points :o) -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails:

[Rails] ActiveRecord::Observer, update_all and has_many

2010-07-14 Thread Rob Nichols
Hi, I'm using an ActiveRecord::Observer to log users changing data in my application. However, I've noted that adding an item to a has_many relationship gets logged, but removing the item does not. That is: @product.users user is logged, but: @product.users.delete(user) is not. I've dug

[Rails] Re: get last record before, or first record after, a given date?

2010-07-14 Thread Rob Nichols
I think this SQL would do it: SELECT * FROM `states` WHERE created_at '2010-04-16' OR created_at = ( SELECT created_at FROM `states` ORDER BY created_at ASC LIMIT 1) ORDER BY created_at DESC LIMIT 1 But your original solution would be easier to maintain! -- Posted via

[Rails] Re: About master page in Rubi on rails

2010-07-14 Thread Rob Nichols
Ziaur Rahman wrote: When I plan to work with ruby I miss studio like visual studio of microsoft Have a look at NetBeans. It's an IDE that works well with Rails. http://netbeans.org/features/ruby/index.html and master pages Have a look at layouts

[Rails] Re: Simple question about submit

2010-07-08 Thread Rob Nichols
Marnen Laibow-Koser wrote: Rob Nichols wrote: Marnen Laibow-Koser wrote: Whatever the form tag's action is. Also, if no action is specified via the form tag, the form is submitted to the current url. So if 'thing/edit/1' contained: form input type=submit / /form The form would

[Rails] Re: order by not ordering as expected...

2010-07-08 Thread Rob Nichols
RubyonRails_newbie wrote: ah yes... :-) It is in the log: 0mSELECT * FROM `blogcomments` ORDER BY created_at desc LIMIT 1 So if it is in the log, why isn't it ordering the comments? 'LIMIT 1' at the end of that SQL query means that only one record is being returned. Either you haven't

[Rails] Re: Nested routes with has_many associations via a :foreign_key

2010-07-06 Thread Rob Nichols
Dee wrote: I'd really like to have nested routes such as /people/1/purchases and / people/1/sales. So I'm kind of surprised I can't do this in Rails You can do it with map.connect. You may have to play with the syntax, but I think this will work: map.connect 'people/:person_id/:controller',

[Rails] Re: Simple question about submit

2010-07-06 Thread Rob Nichols
Marnen Laibow-Koser wrote: Whatever the form tag's action is. Also, if no action is specified via the form tag, the form is submitted to the current url. So if 'thing/edit/1' contained: form input type=submit / /form The form would be submitted back to 'thing/edit/1' -- Posted via

[Rails] define environment for rake db:seed

2010-05-19 Thread Rob Nichols
How do you define which version of the database is populated via the new default seed process? Running this: rake db:seed runs the code in seed.rb in the development environment and therefore loads the seed data into the development database. What is the syntax to use seed to populate the

[Rails] Re: define environment for rake db:seed

2010-05-19 Thread Rob Nichols
tshim wrote: rake db:seed RAILS_ENV=production Thank you. -- 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

[Rails] Re: respond_with and redirects on error

2010-04-15 Thread Rob Nichols
andre...@gmail.com wrote: The last assertion fails, saying the response is a 200 instead of a redirect. Standard rails behaviour is not to redirect if the update fails. If you redirect on failure, the submitted modifications in the form gets over-written. So say you modify a blog altering a

[Rails] Re: add external data at new record creation time

2010-01-04 Thread Rob Nichols
Quee WM wrote: I plan on writing a helper function which will be able to take the id for the new record and return the link. Using a helper function implies that the coding will trigger as the template is being rendered. If this is the case, you don't need an entry in the database. Just write

[Rails] Re: add external data at new record creation time

2010-01-04 Thread Rob Nichols
Rob Nichols wrote: class Vehicle ActiveRecord::Base before_save update_bit_ly_url def update_bit_ly_url bit_ly_url = CreateURL.bit_ly_for_vehicle(self.id) end end Actually - just spotted that you'd have to use after_save or information other than the id to generate the url

[Rails] Re: How to avoid code duplication when validating virtual attributes?

2010-01-04 Thread Rob Nichols
Ben Teese wrote: if from_addresses.size == 1 errors.add('From' address, is not a known sender ) unless Sender.find_by_email_address(from_addresses[0]) else errors.add('From' addresses, expected to contain one email address) end I think your main problem is that the

[Rails] Re: Definitive guide to Rake commands

2009-10-09 Thread Rob Nichols
Thank you again Conrad. I have answered the question that started me down this path. That was, is there a simpler form of rake db:migrate that I could use to migrate non-development databases. However, the reason I posted here was because I thought I may have missed a resource somewhere that

[Rails] Re: Definitive guide to Rake commands

2009-10-08 Thread Rob Nichols
Thank you Greg and Philip $ rake -T rake -T lists the available commands. It doesn't give you any syntax for each command. Specifically, it doesn't list the available parameters and switches. For example, it doesn't specify that you can use the keyword 'environment' with db:migrate.

[Rails] Re: Definitive guide to Rake commands

2009-10-08 Thread Rob Nichols
Rob Nichols wrote: RAILS_ENV=production rake db:migrate That doesn't work on my system, but this does rake db:migrate RAILS_ENV=production Which is better than what I had. It looks like you don't need the 'environment' key word. I might see if I can modify mine to: rake db:migrate

[Rails] Definitive guide to Rake commands

2009-10-07 Thread Rob Nichols
If I want to look up the available Rake command syntax, where do I go to find it? For example, if I want to look up the syntax of a Rails command I can find it at: http://api.rubyonrails.com I can even look up the core Rake api at: http://rake.rubyforge.org/ What I can't find is

[Rails] mysql.so errors with MySQL 5.0.77

2009-02-24 Thread Rob Nichols
I have updated Rails to 2.2.2 and then found I had to update MySQL to work with the mysql gem. However, I've found that with MySQL 5.0.77, I get this error: LoadError (126: The specified module could not be found. - c:/ruby/lib/ruby/gems/1.8/gems/mysql-2.7.3-x86-mswin32/ext/mysql.so) Google

[Rails] Re: Identifying Rails versions related to deprecation warnin

2009-02-20 Thread Rob Nichols
Wes Gamble wrote: Sadly, my impression is that the state of this world has not much improved since I wrote this post so long ago. Thanks for the reply Wes. I was prompted to ask the question on trying to find out why the use of the ActiveSupport::CoreExtensions::Float::Time method 'years'

[Rails] Re: Years gone by (deprecation of years method)

2009-02-20 Thread Rob Nichols
Frederick Cheung wrote: It's to do with http://groups.google.com/group/rubyonrails-core/browse_thread/thread/e546c5a2c3d82da5/8556c83c1d028eff These methods used to be on Numeric, but did weird things with floats, so they were pulled out of Numeric and now only exist (in actual form) on

[Rails] Re: Identifying Rails versions related to deprecation warnin

2009-02-19 Thread Rob Nichols
Wes Gamble wrote: Is there a comprehensive resource for all of the deprecations anywhere? I'd like to ask the same question. Well actually, I don't think I need a comprehensive resource. I'm failing just to find a list. http://www.rubyonrails.org/deprecation just results in a page not found.

[Rails] Re: Restless Rails

2008-11-18 Thread Rob Nichols
Yes, I'd do it with a custom controller method too. Bas van Westing wrote: Hi All, I would advise you to look at recipe 13 Handle Multiple Models in One Form from Advanced Rails Recipies (by Mike Clark, sold by pragmatic programmers). It a little too big to post here, so buy the PDF. I'm

[Rails] Re: Restless Rails

2008-11-15 Thread Rob Nichols
Brian, Thank you for your very nice over-view of using REST. However, I think it also demonstrates one of the problems with the Rails' REST system. It simplifies things when you have a straight-forward requirement, but complicates them if you need to do something outside that model. For

[Rails] Re: Sharing view between new and edit actions

2008-11-13 Thread Rob Nichols
The web designer is wrong in thinking that because you have separate edit and new views files that most of the page is different and not sharing a greate deal of code. They are ignoring the fact that most template view are views within views. Especially if you are using a partial - where you

[Rails] Re: Restless Rails

2008-11-13 Thread Rob Nichols
Thorsten Mueller wrote: Are you talking about REST or CRUD anyway? REST. You can use CRUD without using REST. CRUD describes the separate handling of Create, Read, Update and Delete. You can have separate new/create, show, edit/update, delete/destroy actions in either a RESTful or RESTless