[Rails] nested_form gem don't work for accepts_nested_attributes_for :limit

2011-07-16 Thread danimashu
Hello, I have the next: class Post ActiveRecord::Base has_many :image, :dependent = :destroy accepts_nested_attributes_for :image, :allow_destroy = true, :limit = 4 end class Image ActiveRecord::Base belongs_to :Post ... paperclip settings ... end And the form view for the post is:

[Rails] Re: Uploading files asynchronously

2011-06-28 Thread danimashu
On 28 jun, 06:52, Dheeraj Kumar a.dheeraj.ku...@gmail.com wrote: Usehttp://blueimp.netjquery-based ajax uploader. Thanks Dheeraj. This seems all I needed. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email

[Rails] Re: Uploading files asynchronously

2011-06-28 Thread danimashu
I have been investigating and I have finded Uploadify. What about it compared to Jquery Ajax Uploader? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe

[Rails] Uploading files asynchronously

2011-06-27 Thread danimashu
Hi, now I have working a form for upload images. I'm using 'nested_form', 'paperclip' and 'aws-s3' for storage. All works fine but I would get better. The problem is that the user select the images that want upload but until the user do submit the images is not uploading. It is not nice, because

[Rails] Re: Avoiding repeated results

2011-06-07 Thread danimashu
I'm trying to use select('DISTINCT *') but it doesn't work. Sure, de INNER JOIN between Post and Tagging result of table that all rows are distinct. If we supost the next: Posts Table ID TITLE 1Foo 2FooFaa TAGGINGS Table ID POST_ID TAG_ID 1 11 1

[Rails] Re: Avoiding repeated results

2011-06-07 Thread danimashu
Haven't tried it, but maybe grouping on posts.id would do the right thing? --Matt Jones Hello Matt, thanks for the answer. I've try it and it works fine except when you call to count method later. I've solve it well: scope :finded, lambda {|id| where(:id = id)} scope :tagged, lambda

[Rails] Re: ActiveRecord array/collection manage

2011-06-06 Thread danimashu
Great Valery! I've solved it. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to

[Rails] [scope :tagged] Avoiding repeated results

2011-06-06 Thread danimashu
Hello, I've a usually structure with Post has_many Tags through Taggings. All works well and clean. But I'm having problems with the next scope on Post: scope :tagged, lambda {|tag_id| joins(:taggings).where(:taggings = {:tag_id = tag_id}) } All works fine for call of only one Tag like:

[Rails] ActiveRecord array/collection manage

2011-06-05 Thread danimashu
Hello, I have a model like this: class Car ActiveRecord::Base def color(c) where(color = ?,c) end end Suppose that I want to show the red and blue cars. I could do something like this: @cars = Car.color('blue') + Car.color('red') The problem I'm finding is that now, @cars is an array

[Rails] Re: Collection_select multiple and accepts_nested_attributes_for

2011-05-18 Thread danimashu
Thanks cpr. It isn't work for multiple select control but It's okey for a classic select. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this

[Rails] Re: Collection_select multiple and accepts_nested_attributes_for

2011-05-15 Thread danimashu
Other solution is change the params hash for setup like accepts_nested_attributes_for is expecting. I don't know which is the best solution for do it. In short, I want to create multiple nested objects by selecting from a list. -- You received this message because you are subscribed to the

[Rails] Re: How to count a nested

2011-05-14 Thread danimashu
class Comment   belongs_to :post, :counter_cache = true end class Post   has_many :comments end Thanks so much Kendall, nice solution. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to

[Rails] [Form Helpers] Collection_select multiple and accepts_nested_attributes_for

2011-05-14 Thread danimashu
Hello, I'm triying to set a form but I'm having problems.These are my models: class Post ActiveRecord::Base has_many :taggings, :dependent = :destroy has_many :tags, :through = :taggings accepts_nested_attributes_for :taggings, :limit = 3 end class Tag ActiveRecord::Base has_many

[Rails] Re: Routes - Search url parser

2011-05-11 Thread danimashu
I would advise against a strategy that could ever be ambiguous, even if it looks unlikely at the moment.  It would likely bite you at some point in the future, or even worse the developer who comes hereafter, can you imagine what he/she would say about you when he realised the problem and

[Rails] [Model Scopes] How to count a nested

2011-05-11 Thread danimashu
Hello, I have a Post that has_many Comments. I have the next scopes: scope :valid, where('created_at = ?', 2.months.ago) scope :expired, where('created_at ?', 2.months.ago) Now, I would have a scope named :commented that return all the Post that have more than 0 Comments but I don't know how do

[Rails] Re: Routes - Search url parser

2011-05-10 Thread danimashu
Thanks for the answer. But then what happens with:  - example.com/pink/cadillac  ? In the controller would have to check that pink is a Color and cadillac is a Brand. Problem if some day there is a Brand with name of Color. I don't know if it's worth wasting time on it. The classic way sould

[Rails] Re: Routes - Search url parser

2011-05-09 Thread danimashu
Any help? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more

[Rails] Routes - Search url parser

2011-05-08 Thread danimashu
Hello, I'm trying to set my routes.rb. I have Car that belongs to Color and Brand. I want to build a clear url searcher without visible variables. It's working for me this: resources :Cars match 'color/:color' = 'cars#index' match 'brand/:brand' = 'cars#index' match 'brand/:brand/color/:color' =

[Rails] Re: Routes - Search url parser

2011-05-08 Thread danimashu
For give a example, the url I hope to have is something like that: - example.com/brand/ford/color/red - example.com/brand/ford - example.com/color/red The idea is to have the same that: - example.com/cars?brand=fordcolor=red But really, the user already knows that Ford is a brand and Red is a