[Rails] How to merge multiple 'having' clause relation in rails 3
If i remove any one of scopes having clause then the above action works perfectly . Is there any way to like- @model = Model.vacant_list(daterange) and then remove the active record relation and then apply @model.amenity_type(term). I tried lots of things but didnt find any solution for this. Full question listed here http://stackoverflow.com/questions/6986561/how-to-merge-multiple-having-clause-relation-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-talk@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: raw sql query-update
On 9 August 2011 21:47, Angelo Cordova acord...@gmail.com wrote: Please don't top post, it makes it difficult to follow the thread. Insert your reply at appropriate point(s) in previous post. Thanks. Well I have two non related models, but I need to update an attribute value of one model using a value from the other one. I've tried using callbacks(after_create update_attribute), but it didn't work because they are not related and because I need extra conditions. So I think I could solve this using a raw sql query Having a value in one table dependent on the value in another is often a sign of non-optimal database design. Are you sure that this could not be improved? Even if that is the best solution I don't see why that requires raw sql, or why it could not be done in a callback. Colin On Aug 9, 3:43 pm, Colin Law clan...@googlemail.com wrote: On 9 August 2011 18:34, Angelo Cordova acord...@gmail.com wrote: Hi people I need to write a raw sql query in rails 3. But I don't know where should I do this, in the model or in the controller? If you are not sure where it should be then firstly I would ask whether you are sure you need to write a raw sql query. If you do need to do that then almost always it should be in a model. However without knowing more details of what it does and why, it is impossible to give an absolute answer. 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-talk@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-talk@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: Re: Question about mechanize and input type image
On 9 August 2011 21:08, art tav li...@ruby-forum.com wrote: Colin Law wrote in post #1015781: The first thing to do is to get to valid html. You cannot make any conclusions about anything with invalid html. To check that it is valid view the page source (View Page Source or similar in your browser) copy the complete text and paste it into the w3c html validator. When you have invalid html the browser (which will know that it is invalid) has to guess what you meant and it may not guess the way you intended. There is no point doing anything else until you have valid html. A golden rule of problem solving, if you know that something is not right then fix it before worrying about other things that may or may not be part of the problem. Colin Thanks for this information, i didn't know that w3s have a validator for html, now i can use it to check things faster that using firebug or other things. It seems like the site have a lot of things wrong, like i spected for what i saw the first time in the source code, but the thing here is that i don't own that site so i can't do something about that issues. I don't understand, you are trying to get a form working on a site that you do not have control over? Colin -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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-talk@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: Bundle Install failing on deployment
I have the same error even locally on Rails 3.0.9: /Users/sekrett/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/specification.rb:540:in `normalize_yaml_input': invalid byte sequence in US-ASCII (ArgumentError) mac os x 10.5.8 ruby 1.9.2-p290 bundler 1.0.17 rubygems 1.8.7 -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Bundle Install failing on deployment
Ok, here is the solution, that worked for me: gem 'gherkin', '2.4.5' -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: shp2pgsql error invalid response to ssl negotiation
I tried to convert shape file to postgresql using following command shpe2pgsql -c -D -s 4269 -i -I d:\temp\ublock.shp public.block block.sql Then I throw psql -d testdb -f block.sql when i throw psql command it gives error invalid response to ssl negotiation. Can u pl help me to solve this problem. Prior to convert I have creted a empty table name block in public.schema then i tried to populated ublock.shp to block table. i faild to do this. Please some body help me in this context. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Question about rails generate controller
Thanks! -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] image upload problem
Hi team, I doing one rails application , i have doubt i can create user form and upload images , i did create user(using session ) and create tmp folder and save the database my issue is my error is: undefindedmeth'[]' error came that place: *name= Upload['imagepath'].original_filename* please slove the problem my code : ** @login=Upload.new(params[:userform]) session[:user] = Upload.new(params[:userform]) @sn= session[:user].name @pn= session[:user].email @ss=FileUtils.mkdir_p(tmp/session/#{@sn}) name= Upload['imagepath'].original_filename directory=tmp/session/#{@sn} path=File.join(directory,name) @str=directory+/+name File.open(path,wb){|f|f.write(upload['imagepath'].read)} @upload=Upload.new #@upload=ImagePath.save(params[:upload]) @upload['name']=@sn @upload['email']=@pn @upload['userpath']=@ss #@upload['imagepath']=@str #@upload=DataFile.save(params[:upload]) @upload.save puts puts @sn puts @ss #puts @str end def uploadfile -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Counter gem out there?
Hi, My application is gradually being refined and it is becoming necessary to provide some statistics. I don't really want to add all of these into the main application logic since it is not critical. I would like to observe a bunch of models and classes and increment and decrement counters. So rather than have a bit of hideous AR finds to show me the number of orders by month I can observe the AR callbacks on event and increment August 2011 Orders. I would also need to be able to reset via a Rake task or something similar. Has someone come across a Gem that provides this sort of functionality before I go and write it? O. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: will_paginate appending escape=false to every page URL?
On Aug 9, 2011, at 8:32 PM, Ezequiel Schwartzman wrote: Mislav MarohniÄ? wrote in post #1015695: That might be a bug with older versions. For Rails 3, use will_paginate 3.0.pre4 or later: gem will_paginate, ~ 3.0.pre4 Darn, I feel stupid for not trying that first, thanks haha -- Also, look closely at Kaminari for a nice replacement. I haven't tried Will Paginate on 3, not since I found Kaminari. Walter -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Copy Directory in a generator:
On Aug 9, 2011, at 10:43 PM, jdkealy wrote: How would you copy an entire directory in a generator? I've got tinyMCE and want to copy it from my cms to my new app when running my generator. FileUtils.cp_r( path_1, path_2 ) Walter -- 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-talk@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] A single column with foreign keys from Multiple tables
On Aug 9, 2011, at 2:09 PM, Rahul wrote: Hi, Consider this scenario, I have a table which stores the likes and it would stores the likes from all sorts of tables like blogs,comments, postings, reviews, etc. So the table has the following columns(id, like_id and type) where like_id is the id from any of the previous mentioned tables and type would be single char column to identify the foreign key table(B for blog, C for comments and so on). How am i supposed to create the relation between like table and the other tables? Have a look at any of the polymorphic tagging libraries out there for an architectural model. The last time I did this, I used mbleigh-acts- as-taggable-on (Rails 2.3). But there were lots of other examples out there in that vein. Walter -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Counter gem out there?
Owain wrote in post #1015933: My application is gradually being refined and it is becoming necessary to provide some statistics. I don't really want to add all of these into the main application logic since it is not critical. I would like to observe a bunch of models and classes and increment and decrement counters. So rather than have a bit of hideous AR finds to show me the number of orders by month I can observe the AR callbacks on event and increment August 2011 Orders. I would also need to be able to reset via a Rake task or something similar. Has someone come across a Gem that provides this sort of functionality before I go and write it? Unless there was a requirement for these statistics to be absolutely up-to-date at all times, I don't think I would track them with every change to the models being tracked. Instead, I would probably create a background process to periodically update the counts and store them in a separate statistics table. Essentially mining the statistical information rather than tracking it directly. This also provides an opportunity to flatten some of the relational data, which can dramatically improve query performance for reporting purposes. Consider the example you mentioned; It seems likely that users would be interested in August 2011 Orders sometime in September, or later. It would also be likely that they would want to compare August with the results from August of the prior year. Using data mining techniques these statistics could be provided retroactively, and it would also be possible to update the statistics on a completely separate process or even a separate server leaving your primary application servers free to serve user requests. There are several gems that provide the infrastructure to build something like what I described. For example Github created their own solution, which they have open sourced called Resque: https://github.com/defunkt/resque This would also provide you the rake task for resetting, which would just enqueue another Resque job that you create. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Passing a variable with render
When we want to share a form we make a partial of it: app/views/users/_fields.html.erb %= f.label :name % br / %= f.text_field :name % br / %= f.label :password % br / %= f.password_field :password % and then we implement the code: app/views/users/new.html.erb %= form_for(@user) do |f| % %= render 'fields', :f = f % %= f.submit Submit % % end % in the case of a shared error messaging system: app/views/shared/_error_messages.html.erb % if object.errors.any % %= pluralize(object.errors.count, error) % are present. And those are : br / ul % object.errors.full_messages.each do |msg| % li %= msg % /li % end % /ul % end % and we pass the render code: %= render 'shared/error_messages', :object = f.object % inside the form_for helper My question is why in the case of error_messages partial we pass the f.object and not just f since f is the object itself and in the case of field partian (that holds the form) we pass just f ? Wouldnt it work if we wrote %= render 'shared/ error_messages', :object = f % ? what is the difference? -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Ruby on Rails ebook
http://pragprog.com/book/ltp2/learn-to-program Learn to Program (2nd edition) by Chris Pine For this new edition of the best-selling Learn to Program, Chris Pine has taken a good thing and made it even better. First, he used the feedback from hundreds of reader e-mails to update the content and make it even clearer. Second, he updated the examples in the book to use the latest stable version of Ruby, and also to use code that looks more like real-world Ruby code, so that people who have just learned to program will be more familiar with common Ruby techniques. Not only does the Second Edition now include answers to all of the exercises, it includes them twice. First you’ll find the “how you could do it” answers, using the techniques you’ve learned up to that point in the book. Next you’ll see “how Chris Pine would do it”: answers using more advanced Ruby techniques, to whet your appetite as well as providing sort of a “Rosetta Stone” for more elegant solutions. On Aug 9, 5:18 am, tudor cornea tudor.cor...@gmail.com wrote: On Tue, Aug 9, 2011 at 10:16 AM, Sushil Gupta desus...@gmail.com wrote: I basically understand and have done a little with php/mysql but don't know anything about MVC or Ruby or CoC like that. Can you suggest me any good free ebook that would be suitable for beginners like me? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/odXzuDS6vgwJ. 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. I have found this book to be useful when I started learning. It teaches you different important concepts like authentication, test driven development (rspec), which you will use in your everyday apps: http://ruby.railstutorial.org/ruby-on-rails-tutorial-book You can also check out the tutorials here: http://guides.rubyonrails.org/getting_started.html -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Passing a variable with render
You dont want to pass the whole f object( the form helper object), when you only need the AR instance to loop the object's validation errors. f has methods of its out like text_field , check_box, etc... you dont want to pass f to generate the error list when the instance of the AR is the one with has the method errors. In your example @user is the same as f.object so you could have done %= render 'shared/error_messages', :object= @user % This makes clear what is it that you are passing to the errors loop. AR instances have a method like this @user.errors so you can do @user.errors.each do on the other hand , f is a form helper object, that has methods like f.text_field f.text_area I hope this helps. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: A single column with foreign keys from Multiple tables
On Aug 9, 2:09 pm, Rahul rahulratz...@gmail.com wrote: Hi, Consider this scenario, I have a table which stores the likes and it would stores the likes from all sorts of tables like blogs,comments, postings, reviews, etc. So the table has the following columns(id, like_id and type) where like_id is the id from any of the previous mentioned tables and type would be single char column to identify the foreign key table(B for blog, C for comments and so on). How am i supposed to create the relation between like table and the other tables? Check out the :polymorphic option to belongs_to - it does exactly what you're describing, except for the (premature) optimization of storing a single character for the type. --Matt Jones -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] basic of ROR
Can any one tell where do we find the basic of ROR -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] basic of ROR
On Aug 10, 2011, at 10:11 AM, honey wrote: Can any one tell where do we find the basic of ROR Start here: http://guides.rubyonrails.org/ Best Wishes, Peter -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: image upload problem
I meant to say paperclip instead of will_paginate. That's what I get for reading more than one thread at once :) -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/NESofzPtsXwJ. 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] basic of ROR
If you are disposed to buy a book to learn Rails, consider The Rails 3 Way by Obie Fernandez. Rodrigo Alves Vieira http://www.rodrigoalvesvieira.com http://twitter.com/rodrigoalvieira -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How can I disable Rails 3.1's ActiveRecord Query Caching?
On Aug 8, 9:46 pm, Phoenix Rising polarisris...@gmail.com wrote: Thanks again for your help, Hassan. Unfortunately it's still caching queries. I've tried both approaches in this thread in isolation, and together, and regardless, the query cache is still being used. First, I created an initializer: config/initializers/active_record.rb with ActiveRecord::Base.connection.disable_query_cache! inside it, and then used config.middleware.delete ActiveRecord::QueryCache in config/ environments/development.rb inside the configure block. Unfortunately I'm still left with cached queries inside the log file: Started GET /dashboard for 127.0.0.1 at 2011-08-08 19:43:11 -0600 Processing by DashboardController#index as HTML User Load (12.8ms) SELECT users.* FROM users WHERE users.id = $1 LIMIT 1 [[id, 1]] Do you guys think maybe it's time to submit a bug (for lack of a better word) report for 3.1rc5, or is there another way I should go about testing this? I think you've got the wrong terminology here - you're not seeing any more *query* caching, but the prepared statement stuff is still active. The Rails internals seem to prefer the term statement cache for that functionality, and it doesn't appear to be affected by the switches mentioned here (which affect caching of query *results*). In fact, there doesn't seem to be a way to switch it off at all. I have to admit, I'm not terribly familiar with prepared statements (other than to note that they tend to make repeated queries much faster); if there's a situation where they are causing incorrect operation that's DEFINITELY a bug and should be reported. --Matt Jones -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Where is the Rails-way to place view that is not related to any specific controller?
Well, I have a sidebar in a website that is rendered inside the main layout. What I want to do is to put the sidebar in a separated file and then call = render :partial = sidebar.html.haml Just to have them in separated files. Where is the convention to put it? In the root of /app/views? In /app/views/application? In /app/views/layout? In a separated view folder? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Re: will_paginate appending escape=false to every page URL?
Walter Davis wrote in post #1015942: On Aug 9, 2011, at 8:32 PM, Ezequiel Schwartzman wrote: Mislav Marohni? wrote in post #1015695: That might be a bug with older versions. For Rails 3, use will_paginate 3.0.pre4 or later: gem will_paginate, ~ 3.0.pre4 Darn, I feel stupid for not trying that first, thanks haha -- Also, look closely at Kaminari for a nice replacement. I haven't tried Will Paginate on 3, not since I found Kaminari. Walter Thanks! I will definitely take a look at it! For the curious coming from Google (?) here is a link to a nice tutorial of Kaminari (http://asciicasts.com/episodes/254-pagination-with-kaminari) I found. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] custom methods routing - rails 3
Hi everyone I have a problem with a couple of methods I've created. The first method looks like the edit method but I've renamed to aprove this method load a form with some editable fields def aprove @buy_order = BuyOrder.find(params[:id]) end The second method looks like update, the name is result, but it should execute just after I click submit in the aprove form. But when I click submit... the update method is executed instead def result @buy_order = BuyOrder.find(params[:id]) respond_to do |format| if @buy_order.update_attributes(params[:buy_order]) format.html { redirect_to(@buy_order) } format.xml { head :ok } else format.html { render :action = aprobar} format.xml { render :xml = @buy_order.errors, :status = :unprocessable_entity } end end end What I have to do to make this work correctly? (correctly is: when I click submit in the form for aprove then result has to execute) Can you 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-talk@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: Where is the Rails-way to place view that is not related to any specific controller?
On Aug 10, 4:20 pm, Ezequiel Schwartzman li...@ruby-forum.com wrote: Well, I have a sidebar in a website that is rendered inside the main layout. What I want to do is to put the sidebar in a separated file and then call = render :partial = sidebar.html.haml Just to have them in separated files. Where is the convention to put it? In the root of /app/views? In /app/views/application? In /app/views/layout? In a separated view folder? I often have app/views/shared or things like that. Fred -- 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-talk@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: How can I update a div value using Ajax but calling a function on the OnChange?
Kleber Shimabuku wrote in post #1015905: and the form p class=fields %= f.collection_select(:part_id, @parts, :id, :title, { :prompt = true } , { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); } ) % %= f.label(:part_id, Price: ) % span class=price/span %= f.hidden_field :_destroy % %= link_to_remove_fields remove, f % /p js shouldn't be in your html, i.e. this: { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); should be done up in the head section of your html. In order to do that, you have to put your js inside a function that executes after the page has loaded. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Where is the Rails-way to place view that is not related to any specific controller?
Frederick Cheung wrote in post #1015986: On Aug 10, 4:20pm, Ezequiel Schwartzman li...@ruby-forum.com wrote: In /app/views/application? In /app/views/layout? In a separated view folder? I often have app/views/shared or things like that. Fred Thanks, I'll do that ^^ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Counter gem out there?
On 10 August 2011 13:49, Robert Walker li...@ruby-forum.com wrote: Owain wrote in post #1015933: My application is gradually being refined and it is becoming necessary to provide some statistics. I don't really want to add all of these into the main application logic since it is not critical. I would like to observe a bunch of models and classes and increment and decrement counters. So rather than have a bit of hideous AR finds to show me the number of orders by month I can observe the AR callbacks on event and increment August 2011 Orders. I would also need to be able to reset via a Rake task or something similar. Has someone come across a Gem that provides this sort of functionality before I go and write it? [snipped lots of good stuff from Robert] +1 to what Robert suggested, *but* first I would define methods of the models to provide the stats you are looking for (or define a new statistics class that provides the methods) then initially just do them as AR queries. You have said these will be 'hideous' but they should not be difficult to code. This may apparently be an inefficient way to achieve the answers but it will be simple and will get you functioning (and testable) code quickly and easily. Then, in the fullness of time, if it becomes clear that they take too long to run, you can worry about optimising the execution by running data mining techniques as Robert has suggested. As these will involve refactoring of the methods you started with it will have minimal (if any) effect on the rest of the app. 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-talk@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: Passing a variable with render
ok i think i got it now thank you On Aug 10, 4:45 pm, radhames brito rbri...@gmail.com wrote: You dont want to pass the whole f object( the form helper object), when you only need the AR instance to loop the object's validation errors. f has methods of its out like text_field , check_box, etc... you dont want to pass f to generate the error list when the instance of the AR is the one with has the method errors. In your example @user is the same as f.object so you could have done %= render 'shared/error_messages', :object= @user % This makes clear what is it that you are passing to the errors loop. AR instances have a method like this @user.errors so you can do @user.errors.each do on the other hand , f is a form helper object, that has methods like f.text_field f.text_area I hope this helps. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How can I update a div value using Ajax but calling a function on the OnChange?
now with rails 3.1 doesn't all the java code go in a *.js.coffee file inside the app/assets/javascripts/ ? or do we write it on the corresponding view directly? On Aug 10, 7:05 pm, 7stud -- li...@ruby-forum.com wrote: Kleber Shimabuku wrote in post #1015905: and the form p class=fields %= f.collection_select(:part_id, @parts, :id, :title, { :prompt = true } , { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); } ) % %= f.label(:part_id, Price: ) % span class=price/span %= f.hidden_field :_destroy % %= link_to_remove_fields remove, f % /p js shouldn't be in your html, i.e. this: { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); should be done up in the head section of your html. In order to do that, you have to put your js inside a function that executes after the page has loaded. -- 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-talk@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: Decrypt a admin password (with salt)
md5(md5(md5(Password-With-Salt)))=2787551f694768be48c6944a3a1e6b6d -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] custom methods routing - rails 3
On 10 August 2011 16:31, Angelo Cordova acord...@gmail.com wrote: Hi everyone I have a problem with a couple of methods I've created. The first method looks like the edit method but I've renamed to aprove this method load a form with some editable fields def aprove @buy_order = BuyOrder.find(params[:id]) end The second method looks like update, the name is result, but it should execute just after I click submit in the aprove form. But when I click submit... the update method is executed instead When you click submit in the aprove form the action that is run depends on the code in that view. It is there that you must look to see what action you have asked it to perform. 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-talk@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] Correct MVC pattern for Model sending an IM message
Hi, I have an application that has a model that wants to send an IM message on its state change. In that IM message I want to format some HTML, include a link, etc. However, none of the rails view helpers that I'd like to use (i.e. link_to and url_for) are available to the model. Looking around on the web there are various ways to get those to work in the model, or to give the model the ability to render files/ strings and put the stuff there. But, the caveat on all of those is that they all break the MVC conventions, likely indicating an issue with the design/architecture. So, my question is what would be the correct MVC pattern to accomplish this? Its the state change of the model that triggers the need to send the IM message, to get the message string is a ~render~, but how does the model accomplish this in the correct way? Thanks, \Peter -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] STI Devise, remove sign up for admin
Hi, If I'm using STI with Devise, I have a Admin model inheriting the base Devise User model. I would like to remove 'registerable' from the Admin model but it inherits registerable from the user model. How would i disable registration for admins? -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Question about mechanize and input type image
That's correct, so i can't change the form or the input image for a button. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Where is the Rails-way to place view that is not related to any specific controller?
I'd rather put them in app/views/layouts since app/views/shared seems a bit vague for me. On Aug 10, 2011, at 1:09 PM, Ezequiel Schwartzman wrote: Frederick Cheung wrote in post #1015986: On Aug 10, 4:20pm, Ezequiel Schwartzman li...@ruby-forum.com wrote: In /app/views/application? In /app/views/layout? In a separated view folder? I often have app/views/shared or things like that. Fred Thanks, I'll do that ^^ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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-talk@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] Sqlite 3 install error on Heroku, Rails 3.1
Maybe it's because Heroku doesn't use sqlite in production, instead it uses Postgres. I think you should try to restrict the sqlite3 gem in your Gemfile only to the development environment. Cheers! Rodrigo Alves Vieira http://www.rodrigoalvesvieira.com http://twitter.com/rodrigoalvieira -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Where is the Rails-way to place view that is not related to any specific controller?
Ruby on Rails 3 Tutorial puts them in the layouts directory, e.g. layouts/_sidebar.html.erb, which are then inserted with: % render 'layouts/sidebar' % -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: javascript_include_tag error
I guess I can always just do this: script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js; /script script type=text/javascript, src=jquery.rails.js /script but I'm still wondering why I got the error. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Puzzling error
I am getting: uninitialized constant RbConfig::RetusersController My routes look like this: map.namespace(:config) do |config| config.resources :users do |user| user.resources :retusers end end and I am calling redirect with: redirect_to edit_config_user_retuser_url(application_user, retuser) where application_user is a User and retuser is a Retuser. In app/controllers/retusers_controller.rb I have: class RetusersController ApplicationController ... end On my development platform, I do not get the error. On my production platform I do. The two should be the same ruby and set of gems. This is using Rails 2.3.11 and Ruby 1.9.1. What am I doing wrong? Thank you, pedz -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Counter gem out there?
Consider the example you mentioned; It seems likely that users would be interested in August 2011 Orders sometime in September, or later. It would also be likely that they would want to compare August with the results from August of the prior year. Using data mining techniques these statistics could be provided retroactively, and it would also be possible to update the statistics on a completely separate process or even a separate server leaving your primary application servers free to serve user requests. Rob This was my starting position, i.e. download a load of data into some other tool (excel) and do the analysis there. I am looking for more real-time counters that can be used for a dashboard to graph order volumes and so forth so I really want it to be performant. Every time the user goes to order statistics I do not want to have to do a huge amount of DB access. There are several gems that provide the infrastructure to build something like what I described. For example Github created their own solution, which they have open sourced called Resque: https://github.com/defunkt/resque This would also provide you the rake task for resetting, which would just enqueue another Resque job that you create. Resque is a background job queue, I currently use delayed_job for sending emails. Unless I am mistaken I am not sure this is really much help. I am not expecting to have to run the reset task that often so running it from the command line will suffice. -- 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-talk@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] Simplify code on method about 4 models
I'm trying to get more into the Ruby mindset. I know I should accomplish more with less code. I came up with this method that does work, but I think could really use some simplification. There is 4 models. Account Company (belongs to Account) User (belongs to Company) (belongs to Role) (to get the account id, I would need to do user.company.account_id) Role User.role_id (if it's a 1, it means it's the Account Owner) There is only ONE account owner per account. So, when a customer(role_id=4) signs in, under the Users tab, he's supposed to see two companies: 1) the company he belongs to 2) and the account owners company So I need to come up with something like this: @companies = Company.all(:conditions = [id == ? or id == ?, current_user.company_id, account_owner_company_id]) 1) Coming up with the company he belongs to it's easy: current_user.company_id 2) Coming up with the account owner company id it's more difficult and requires several queries. The method I have does the following: a) Finds the customer's account_id b) Looks for ALL account owners in the database c) Tries to match the customer's account_id to one of the account owners id's d) Finally, returns the account owner's company id --- def account_owner_company_id customer_account_id = current_user.company.account_id account_owners = User.find_all_by_role_id(1) account_owners.each do |ao| if ao.company.account_id == customer_account_id @this_one = ao.company_id end end @this_one end --- You can easily see that if the database grows, looking for ALL account owners in the database can take up a lot of resources. Can you suggest an easier way to find the account owner company id when being logged in as a customer? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Question About Forms
This is more of a design question. There is nothing wrong with many forms. And usually keeping things separate leads to more stable, easier to maintain code. So I would probably opt for many small forms rather than one big one. HTH pedz -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Help with Custom Mail Header
Hi - I'm stuck on something 'simple' - custom mail header. Seems this should work but can't get it to come out correctly. Any help appreciated: http://pastie.org/private/skedkstanvm8hpzr8ounia -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Ruby on Rails ebook
Here are a couple of resources for learning ruby and ROR. http://tryruby.org/ for a basic intro to ruby http://railsforzombies.org/ for Rails I also have used the rails tutorial that Rails Rider mentioned Take a look at http://railscasts.com/ for more in depth Rails topics. Not sure where you are located, but sometimes libraries have good books on Ruby and some even have ebooks that you can check out. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/MJM_cquw9AwJ. 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] (Job) Ruby on Rails in NJ area,New Jersey
*Hello,* * * *Reply back to this email id **allendeepa...@preludesys.com* * * * * *Job Title : Ruby on Rails* *Location : NJ area, New Jersey* *Project Duration : 6 Month(s)* *Est Start Date : mid sep 2011* *Skill Set :* We need strong leads who have experience in website development using Ruby on Rails. This is a brand new development project where we have this need. They will need to work in Agile mode in an environment *Education :* Bachelors Degree *For interview purpose we need the following details, So please fill the required details and send back with your updated Resume* * * *For** **interview purpose**, we need the following :** *** *First Name:* *Last Name:* *Present location: * *Interview Contact number: * *Other Contact numbers (Home/Mobile/Work): * *Preferable Interview time: * *Face to Face (Yes/No): * *E-mail ID: *** *Availability: * *Overall IT experience:* *Work Authorization: * *Allen* [image: cid:image003.png@01CA0ED7.54E34B20] *Direct: 213-233-3907* *Fax: 562-683-2176* *Email: **allendeepa...@preludesys.com*** *URL: **www.preludesys.com*** *Linkedin:*PreludeSys - Linkedinhttp://www.linkedin.com/profile/view?id=128874079authType=NAME_SEARCHauthToken=kZ78locale=en_USsrchid=aabbf7f2-3421-420b-8920-ef1e82545be0-0srchindex=16srchtotal=16goback=%2Efps_PBCK_Preludesys+recruitment_*1_*1_*1_*1_*1_*1_*2_*1_Y_*1_*1_*1_false_2_ ** -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Counter gem out there?
On Aug 10, 5:09 pm, Colin Law clan...@googlemail.com wrote: On 10 August 2011 13:49, Robert Walker li...@ruby-forum.com wrote: Owain wrote in post #1015933: My application is gradually being refined and it is becoming necessary to provide some statistics. I don't really want to add all of these into the main application logic since it is not critical. I would like to observe a bunch of models and classes and increment and decrement counters. So rather than have a bit of hideous AR finds to show me the number of orders by month I can observe the AR callbacks on event and increment August 2011 Orders. I would also need to be able to reset via a Rake task or something similar. Has someone come across a Gem that provides this sort of functionality before I go and write it? [snipped lots of good stuff from Robert] +1 to what Robert suggested, *but* first I would define methods of the models to provide the stats you are looking for (or define a new statistics class that provides the methods) then initially just do them as AR queries. You have said these will be 'hideous' but they should not be difficult to code. This may apparently be an inefficient way to achieve the answers but it will be simple and will get you functioning (and testable) code quickly and easily. Then, in the fullness of time, if it becomes clear that they take too long to run, you can worry about optimising the execution by running data mining techniques as Robert has suggested. As these will involve refactoring of the methods you started with it will have minimal (if any) effect on the rest of the app. Colin, That was exactly my first thought but I think the statistics are really just observing the application, not the application itself. So rather than having a whole load of class methods on the models to provide the data I can use an Observer class per model, or even better one Observer class that collects the statistics for all of the relevant models. So only the statistics Observer class ever changes as the requirements for the statistics changes over time. The idea came from the article http://railstips.org/blog/archives/2011/06/28/counters-everywhere/ by John Nunemaker (I recommend his posts for some great ideas). He has coded this in a MongoDB environment, basically a key-value pair. Here is some pseudo code not implemented, class Amodel ActiveRecord::Base # nothing here end class StatisticsObserver ActiveRecord::Observer observe Amodel#can you register more than one class per Observer or create a parent class for statistics? def after_create(obj) increment_counter(a) end def after_update(obj) update_counter(a) end end So the counter (i.e. the key) would simply be based upon the object attributes concatenated with some sort of time derivative. So we could track sunday orders above a certain value by month and hide all of that logic in the Observer. Then pulling the values of these counters should be easy for creating charts, reports and so forth. O. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Question about mechanize and input type image
On 10 August 2011 18:14, art tav li...@ruby-forum.com wrote: That's correct, so i can't change the form or the input image for a button. OK, sorry, I had forgotten what your original question was. I was thinking that you were describing a problem specific to the form that you provided the detailed html for. Your best bet might be the mechanize mailing list (see http://mechanize.rubyforge.org/). Of course it may be that what you want to do is not possible as mechanize might not be capable of interpreting the invalid html. 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-talk@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] sql query in a more rails 3 way
Hi people I want to know if you know how to write the following sql query in a more rails way UPDATE buy_order_detail SET saldo = saldo - detail_purchase.cantidad FROM purchase_detail INNER JOIN purchase ON purchase.id = purchaser_detail.purchase_id INNER JOIN waybill ON waybill.id = purchase.waybill_id INNER JOIN buy_order ON buy_order.id = waybill.order_id INNER JOIN buy_order_detail ON buy_order.id = buy_order_detail.order_id WHERE purchase_detail.product_id = buy_order_detail.product_id -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Join Table Validation Question
Hi All, Here's my situation. People have Availability for Events. I need to ensure that each Person is Available for each Event exactly once. I'm thinking the way to do it would be with a before_save method in Availability that does an Availability.find(event_id = ? and person_id = ?, record.event_id, record.person_id) and complains if it finds one. Is this the way to go or is there a better approach? **Leigh = #Person.rb class Person ActiveRecord::Base has_many :availabilities has_many :events, :through = :availabilities default_scope :order = 'name ASC' validates_presence_of :name, :on = :create, :message = -- You need to enter your name end #Availability.rb class Availability ActiveRecord::Base belongs_to :event belongs_to :person validates_presence_of :person_id, :on = :create, :message = can't be blank validates_presence_of :event_id, :on = :create, :message = can't be blank end #Event.rb class Event ActiveRecord::Base has_many :availabilities has_many :people, :through = :availabilities default_scope :order = 'date ASC' validates_presence_of :name, :on = :create, :message = can't be blank validates_presence_of :date, :on = :create, :message = can't be blank end # Schema.rb ActiveRecord::Schema.define(:version = 20110809224443) do create_table availabilities, :force = true do |t| t.integer event_id t.integer person_id . . . end create_table events, :force = true do |t| t.string name t.datetime date . . . end create_table people, :force = true do |t| t.string name . . . end end -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Simplify code on method about 4 models
On Aug 10, 7:54 pm, Leonel *.* li...@ruby-forum.com wrote: --- You can easily see that if the database grows, looking for ALL account owners in the database can take up a lot of resources. Can you suggest an easier way to find the account owner company id when being logged in as a customer? Your data structure feels a little weird to me - Presumably accounts have multiple companies. So does someone with role_id == 1 own all the companies in the account that the company_id points to? It feels a little lopsided to have this one privileged company. I think personally I would give account an owner_id attribute. Anyway, assuming that users will grow rapidly but that an account will only ever have a manageable number of companies in it, something like all_companies_in_account = current_user.company.account.companies owner = User.find_by_role_id_and_company_id(1, all_companies_in_account) would find you the owner. Fred -- 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-talk@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] Help with Custom Mail Header
On 10 Aug 2011, at 16:35, Adam O'Connor wrote: I'm stuck on something 'simple' - custom mail header. Seems this should work but can't get it to come out correctly. Any help appreciated: http://pastie.org/private/skedkstanvm8hpzr8ounia In your call to #mail: mail(:to = 't...@sample.com', :from = email, :subject = Message from the site, :headers['X-SMTPAPI'] = {\category\ : \Drip Email\} ) you're passing a hash of headers to the #mail method, and one of your keys is :headers['X-SMTPAPI']. Ruby tries to execute this as calling the #[] method on the symbol :headers, which returns nil (under ActiveSupport). This all happens before the #mail method gets a chance to see it; in other words, your method call looks like this: mail(:to = 't...@sample.com', :from = email, :subject = Message from the site, nil = {\category\ : \Drip Email\} ) That's why you're seeing the {category : Drip Email} value appear in your email, but with an empty name for the header. To set a header value, you can either specify it directly in the hash you pass to #mail: mail(:to = 't...@sample.com', :from = email, :subject = Message from the site, 'X-SMTPAPI' = {\category\ : \Drip Email\} ) or you can use the #headers method separately: headers['X-SMTPAPI'] = {\category\ : \Drip Email\} mail(:to = 't...@sample.com', :from = email, :subject = Message from the site ) 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-talk@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: Puzzling error
On Aug 10, 7:47 pm, Perry Smith li...@ruby-forum.com wrote: I am getting: uninitialized constant RbConfig::RetusersController My routes look like this: map.namespace(:config) do |config| config.resources :users do |user| user.resources :retusers end end and I am calling redirect with: redirect_to edit_config_user_retuser_url(application_user, retuser) where application_user is a User and retuser is a Retuser. In app/controllers/retusers_controller.rb I have: class RetusersController ApplicationController ... end On my development platform, I do not get the error. On my production platform I do. The two should be the same ruby and set of gems. This is using Rails 2.3.11 and Ruby 1.9.1. What am I doing wrong? Well on ruby 1.9.2, the Config constant is an alias for RbConfig, which I think is the root of your troubles. Why it happens only in production I don't know. (probably not a factor, ruby 1.9.2 is the first ruby 1.9 version I'd want to use in production) Fred Thank you, pedz -- 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-talk@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: Join Table Validation Question
On Aug 10, 8:42 pm, Leigh Daniels leighdaniel...@gmail.com wrote: Hi All, Here's my situation. People have Availability for Events. I need to ensure that each Person is Available for each Event exactly once. I'm thinking the way to do it would be with a before_save method in Availability that does an Availability.find(event_id = ? and person_id = ?, record.event_id, record.person_id) and complains if it finds one. Is this the way to go or is there a better approach? I'd stick a unique index on that pair of columns too - it's the only way to get a cast iron guarantee for this sort of thing. Fred **Leigh = #Person.rb class Person ActiveRecord::Base has_many :availabilities has_many :events, :through = :availabilities default_scope :order = 'name ASC' validates_presence_of :name, :on = :create, :message = -- You need to enter your name end #Availability.rb class Availability ActiveRecord::Base belongs_to :event belongs_to :person validates_presence_of :person_id, :on = :create, :message = can't be blank validates_presence_of :event_id, :on = :create, :message = can't be blank end #Event.rb class Event ActiveRecord::Base has_many :availabilities has_many :people, :through = :availabilities default_scope :order = 'date ASC' validates_presence_of :name, :on = :create, :message = can't be blank validates_presence_of :date, :on = :create, :message = can't be blank end # Schema.rb ActiveRecord::Schema.define(:version = 20110809224443) do create_table availabilities, :force = true do |t| t.integer event_id t.integer person_id . . . end create_table events, :force = true do |t| t.string name t.datetime date . . . end create_table people, :force = true do |t| t.string name . . . end end -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rake seems to have stopped working.
I am using rails 3.0.7 and my database is postgresql and my OS is Suse Linux 10.1 Somehow a problem created into my system and I don't know how. After using rake successfully many times, I then started getting the error message You have already activated rake 0.9.0 but your gem file requires rake 0.8.7 …. Based on other posts here I used 'gem uninstall rake – v=0.9.0' to uninstall, after which rake started running to completion again. Somewhat. I ran 'rails generate scaffold card' and this worked with no issues. Then I run rake db:migrate This also seems to work, I get the standard postgresql messages: Notice: CREATE TABLE will create implicit sequence ... Notice: CREATE TABLE / PRIMARY KEY will create immplicit index ... However, when done there is no table. I logged in as user postgres and ran pgsql against my database but no new table shows up! To be sure, I then opened every database on my system and confirmed that no table by the name of 'card' exists anywhere! Any ideas why this happens? Better yet, any suggestions on how to get rake going again? Thanks in advance for any help. -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-talk@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: Puzzling error
Hi, Thanks. Yea. I'm trying to get this stable before moving to 1.9.2... but I'm getting into a circular problem. I was on 1.9.1 before 1.9.2 came out. So long story short it sounds like I don't want to use config as a namespace. Thank you for your help pedz -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Rake seems to have stopped working.
As a follow-up question, does anyone know if I can just create the table by hand and then continue as if nothing happened, and expect rails to behave normally? -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Simplify code on method about 4 models
Thanks Fred! The reason of this setup (might need some adjusting) is that an Account has an attribute paying_method. So only the account_owner is the one that pays. The account owner can add, edit or delete Companies and Users. He's the administrator for that Account. The Users under the account owner's Company, are kinda like managers or agents. The Users under other than the account owner's company are customers. __ ACCOUNT OWNER AND AGENTS __ So let's say Tom is the account owner. His company is Landscaping Solutions. He pays the app. - Users under his company (agents) can open, modify and close tickets. Tom (user, role: account owner) Rick (user, role: agent) Pam (user, role:agent) - ___ CUSTOMERS So Tom invites other creates companies and invites users. Customers can only open tickets. Goliath National Bank (company) Barney (user, role: customer) Marshall (user, role: customer) Mobious Designs (company) Ted (user, role: customer) -- -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Join Table Validation Question
On Aug 10, 8:42 pm, Leigh Daniels leighdaniel...@gmail.com wrote: Hi All, Here's my situation. People have Availability for Events. I need to ensure that each Person is Available for each Event exactly once. I'm thinking the way to do it would be with a before_save method in Availability that does an Availability.find(event_id = ? and person_id = ?, record.event_id, record.person_id) and complains if it finds one. Is this the way to go or is there a better approach? I'd stick a unique index on that pair of columns too - it's the only way to get a cast iron guarantee for this sort of thing. Is this what you meant, Fred? add_index availabilities, [person_id, event_id], :name = person_id_event_id, :unique = true **Leigh Fred **Leigh = #Person.rb class Person ActiveRecord::Base has_many :availabilities has_many :events, :through = :availabilities default_scope :order = 'name ASC' validates_presence_of :name, :on = :create, :message = -- You need to enter your name end #Availability.rb class Availability ActiveRecord::Base belongs_to :event belongs_to :person validates_presence_of :person_id, :on = :create, :message = can't be blank validates_presence_of :event_id, :on = :create, :message = can't be blank end #Event.rb class Event ActiveRecord::Base has_many :availabilities has_many :people, :through = :availabilities default_scope :order = 'date ASC' validates_presence_of :name, :on = :create, :message = can't be blank validates_presence_of :date, :on = :create, :message = can't be blank end # Schema.rb ActiveRecord::Schema.define(:version = 20110809224443) do create_table availabilities, :force = true do |t| t.integer event_id t.integer person_id . . . end create_table events, :force = true do |t| t.string name t.datetime date . . . end create_table people, :force = true do |t| t.string name . . . end end -- 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 options, visit this group at http://groups.google.com/group/ rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Where is the Rails-way to place view that is not related to any specific controller?
7stud -- wrote in post #1016015: Ruby on Rails 3 Tutorial puts them in the layouts directory, e.g. layouts/_sidebar.html.erb, which are then inserted into the application layout with: % render 'layouts/sidebar' % That seems rational, since the scaffolding creates a _form element, thanks ^^ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] [JOB] Senior Rails Developer, New York City | 120-140k
*** Junior and mid-level developers needed as well. Relocation OK! This is a full time, on-site, salaried Senior Ruby on Rails Developer position paying $120,000-$140,000 depending on experience + benefits. No telecommuting allowed. US Citizens or Green Card holders only please. Local candidates strongly preferred, but candidates interested in relocating considered as well. Full company details provided to qualified applicants. Thank you. Our New York City client (near Union Square Park) is looking for Ruby on Rails engineers to join its team. They are building an extensive platform using best of breed technologies including Ruby on Rails (just upgraded to Rails 3), jQuery, MongoDB, Redis, Resque, Rspec and Cucumber. You’ll be working in an agile environment where we keep things simple and where we love testing and refactoring – we always make sure our continuous integration build stays green on master. Come excited to contribute to a passionate, visionary team with deep experience and relentless drive. Responsibilities: * Design, build and test the core components of the platform partnering with the product and business development teams to improve and extend our awesome product * Investigate innovative solutions to platform requirements, thinking outside the box to get things done * Continuously refactor code base to ensure it is maintainable * Optimize slow performing web transactions * Become a leader on the team helping grow and mentor new engineers Must Haves: * The more experience you have building web applications using Ruby on Rails the better * JavaScript/JQuery experience * Git experience Very Nice to Haves: * Experience building RoR plugins or Ruby gems * Experience scaling web applications to handle millions of users * Be a BDD nut who’ll know when a LOD violation is actually a violation and will never allow code to go to production unless it has been tested * Contribution to open source projects or side projects * Experience with Mongo * Experience with Amazon Web Services (EC2, S3, etc…) * Experience developing APIs If you are interested in this job, please submit your RESUME and SALARY requirements to opensourcestaffing|AT|gmail.com Thank you, Beau J. Gould -- Open Source Staffing http://opensourcestaffing.wordpress.com opensourcestaffing|AT|gmail.com Follow me on Twitter: ossjobs -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Where is the Rails-way to place view that is not related to any specific controller?
However, when you try to include a partial render from a layout and it is missing you can see that the paths where it search for the view are views/application and views/controller. So I assume that: shared partial renders should go into views/applications controller specific partial renders should go into views/controller both should be named with a starting underscore and called without it however if you wish to render the partial view from another controller you have to select the path calling render controller/partial_view At least that's how I'm going to do from now on ^^ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Nested Attributes and Radio Buttons -- any way to do this?
I have the following: class Title has_many :roles has_many :people, :through = :roles accepts nested_attributes_for :roles (Roles and People are also correctly defined) In my title#edit view, I have the fields_for set up correctly and working: %= f.fields_for :roles do |builder| % %= render role_fields, :f = builder % %- end -% and in the role_fields partial, I have %= f.check_box :primary % %= f.label :primary % Now I would like to change the check_box (which does work correctly) into a radio button, so only one of the nested roles would be the primary role. How can I use nested attributes and radio buttons? If I replace the f.check_box call with f.radio_button( :primary, true ) I end up with a radio group that acts like a bunch of individual radio groups -- I can click on any of them and each one will check on without deselecting any of the others. If I change the name, so that each button has the same name, then the radio group works as expected, but the nested form breaks. I need those unique index names (title[roles_attributes][0][primary], title[roles_attributes][1][primary], title[roles_attributes][3] [primary], etc.) to set the primary attribute on the correct nested role. Short of using JavaScript to enforce the one-radio-button-at-a-time rule here, is there any way to do a nested form with radio buttons like this? Thanks in advance, Walter -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: How can I update a div value using Ajax but calling a function on the OnChange?
@7stud, the onchange behavior make a function call, that's right, and this function (load_part_price_select() ) belongs to a js file, in this case I did put it on the application.js file. this is actually working for me. @Filippos, I haven't installed rails 3.1 yet, still on 3.0.9 for now, so I can't tell you that, sorry. On Aug 11, 1:25 am, Filippos filippos...@gmail.com wrote: now with rails 3.1 doesn't all the java code go in a *.js.coffee file inside the app/assets/javascripts/ ? or do we write it on the corresponding view directly? On Aug 10, 7:05 pm, 7stud -- li...@ruby-forum.com wrote: Kleber Shimabuku wrote in post #1015905: and the form p class=fields %= f.collection_select(:part_id, @parts, :id, :title, { :prompt = true } , { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); } ) % %= f.label(:part_id, Price: ) % span class=price/span %= f.hidden_field :_destroy % %= link_to_remove_fields remove, f % /p js shouldn't be in your html, i.e. this: { :onchange = load_part_price_select(this.id, this.options[this.selectedIndex].value); should be done up in the head section of your html. In order to do that, you have to put your js inside a function that executes after the page has loaded. -- 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-talk@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: weird problem when updating to RC5
@tenderlove yanked the troublesome 2.1.5 gem: https://github.com/rails/arel/issues/72 Problem solved. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Simplify code on method about 4 models
I think you can dispense with Company altogether and just have an association class describing a User's relationship to an Account: ``` Account has_many :users, :through = :memberships User belongs_to :account Membership belongs_to :user belongs_to :account has_one :role # agent, owner, etc. ``` ~ jf -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Wed, Aug 10, 2011 at 16:20, Leonel *.* li...@ruby-forum.com wrote: Thanks Fred! The reason of this setup (might need some adjusting) is that an Account has an attribute paying_method. So only the account_owner is the one that pays. The account owner can add, edit or delete Companies and Users. He's the administrator for that Account. The Users under the account owner's Company, are kinda like managers or agents. The Users under other than the account owner's company are customers. __ ACCOUNT OWNER AND AGENTS __ So let's say Tom is the account owner. His company is Landscaping Solutions. He pays the app. - Users under his company (agents) can open, modify and close tickets. Tom (user, role: account owner) Rick (user, role: agent) Pam (user, role:agent) - ___ CUSTOMERS So Tom invites other creates companies and invites users. Customers can only open tickets. Goliath National Bank (company) Barney (user, role: customer) Marshall (user, role: customer) Mobious Designs (company) Ted (user, role: customer) -- -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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-talk@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] Write to file with a Generator
Hi, Is there some way to write to a model file to show a relationship with a generator? Like write to a User file for instance? And say has_many :testimonials or something like that? I know i could do this with Ruby. I was just wondering if there was a rails way. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Join Table Validation Question
On Aug 10, 9:23 pm, Leigh Daniels leighdaniel...@gmail.com wrote: On Aug 10, 8:42 pm, Leigh Daniels leighdaniel...@gmail.com wrote: Hi All, Here's my situation. People have Availability for Events. I need to ensure that each Person is Available for each Event exactly once. I'm thinking the way to do it would be with a before_save method in Availability that does an Availability.find(event_id = ? and person_id = ?, record.event_id, record.person_id) and complains if it finds one. Is this the way to go or is there a better approach? I'd stick a unique index on that pair of columns too - it's the only way to get a cast iron guarantee for this sort of thing. Is this what you meant, Fred? add_index availabilities, [person_id, event_id], :name = person_id_event_id, :unique = true That's the one. 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-talk@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: Simplify code on method about 4 models
Sorry, typo. Should be: ``` Account has_many :users, :through = :memberships User has_many :accounts, :through = :memberships Membership belongs_to :user belongs_to :account has_one :role # agent, owner, etc. ``` -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Wed, Aug 10, 2011 at 18:15, John Feminella jo...@bitsbuilder.com wrote: I think you can dispense with Company altogether and just have an association class describing a User's relationship to an Account: ``` Account has_many :users, :through = :memberships User belongs_to :account Membership belongs_to :user belongs_to :account has_one :role # agent, owner, etc. ``` ~ jf -- John Feminella Principal Consultant, BitsBuilder LI: http://www.linkedin.com/in/johnxf SO: http://stackoverflow.com/users/75170/ On Wed, Aug 10, 2011 at 16:20, Leonel *.* li...@ruby-forum.com wrote: Thanks Fred! The reason of this setup (might need some adjusting) is that an Account has an attribute paying_method. So only the account_owner is the one that pays. The account owner can add, edit or delete Companies and Users. He's the administrator for that Account. The Users under the account owner's Company, are kinda like managers or agents. The Users under other than the account owner's company are customers. __ ACCOUNT OWNER AND AGENTS __ So let's say Tom is the account owner. His company is Landscaping Solutions. He pays the app. - Users under his company (agents) can open, modify and close tickets. Tom (user, role: account owner) Rick (user, role: agent) Pam (user, role:agent) - ___ CUSTOMERS So Tom invites other creates companies and invites users. Customers can only open tickets. Goliath National Bank (company) Barney (user, role: customer) Marshall (user, role: customer) Mobious Designs (company) Ted (user, role: customer) -- -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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-talk@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] f.collection_select: what are the parameters?
The rails docs are so horrible on the collection_select method. They need to show a *complete* form, and show two examples: one that calls f.collection_select(), and another that calls collection_select(), and explain the differences. Given this line: f.collection_select :topic, Topic.all, :id, :category What the !@#$!@#$ is :topic? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] f.collection_select: what are the parameters?
the field name: collection_select(:post, :author_id, Author.all, :id, :name_with_initial, :prompt = true) will generate: select name=post[author_id] option value=Please select/option option value=1 selected=selectedD. Heinemeier Hansson/option option value=2D. Thomas/option option value=3M. Clark/option /select look fella, for docs look at http://apidock.com/rails is awesome and much better see ya and any questions, please just ask :) Em 10/08/2011, às 21:52, 7stud -- escreveu: The rails docs are so horrible on the collection_select method. They need to show a *complete* form, and show two examples: one that calls f.collection_select(), and another that calls collection_select(), and explain the differences. Given this line: f.collection_select :topic, Topic.all, :id, :category What the !@#$!@#$ is :topic? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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-talk@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: f.collection_select: what are the parameters?
Given this line: f.collection_select :topic, Topic.all, :id, :category If I give rails a collection (Topic.all), and the value attribute of the option tag (:id), and the display text (:category), why would rails need to know anything else? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: f.collection_select: what are the parameters?
Leoncio Caminha wrote in post #1016087: the field name: collection_select(:post, :author_id, Author.all, :id, :name_with_initial, :prompt = true) will generate: select name=post[author_id] option value=Please select/option option value=1 selected=selectedD. Heinemeier Hansson/option option value=2D. Thomas/option option value=3M. Clark/option /select Okay, so it looks like the first two arguments determine the name of the select? But don't the arguments change if you call: f.collection_select() ??? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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] Inflector Issue?
Hi, just stubbing out an app with Rails3, and I've run into a snag trying to generate a scaffold for Equipment. Namely, the following happens: $ rails generate scaffold Equipment name:string $ cat app/views/home/index.html.erb %= link_to Equipment, equipment_path % br Hitting the index gives this error: No route matches {:action=show, :controller=equipment} I've looked around the web a bit, and tried playing with config/ initializers/inflections.rb (specifying that equipment is uncoutable), but that didn't help. Also, checking on the rails console shows that equipment already pluralizes to equipment, so I'm not sure what the exact issue is. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: f.collection_select: what are the parameters?
7stud -- wrote in post #1016089: Leoncio Caminha wrote in post #1016087: the field name: collection_select(:post, :author_id, Author.all, :id, :name_with_initial, :prompt = true) will generate: select name=post[author_id] option value=Please select/option option value=1 selected=selectedD. Heinemeier Hansson/option option value=2D. Thomas/option option value=3M. Clark/option /select Okay, so it looks like the first two arguments determine the name of the select? And even that isn't entirely correct. Apparently, the name of the select has to be of the form: an_existing_model[:an_existing_field_name_in_that_model] which doesn't make any sense to me. But don't the arguments change if you call: f.collection_select() ??? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: f.collection_select: what are the parameters?
On Aug 10, 2011, at 9:53 PM, 7stud -- wrote: 7stud -- wrote in post #1016089: Leoncio Caminha wrote in post #1016087: the field name: collection_select(:post, :author_id, Author.all, :id, :name_with_initial, :prompt = true) will generate: select name=post[author_id] option value=Please select/option option value=1 selected=selectedD. Heinemeier Hansson/ option option value=2D. Thomas/option option value=3M. Clark/option /select Okay, so it looks like the first two arguments determine the name of the select? And even that isn't entirely correct. Apparently, the name of the select has to be of the form: an_existing_model[:an_existing_field_name_in_that_model] which doesn't make any sense to me. I'm not sure why that is -- you're inside of a form builder, building a form for an object that you plan to modify when you submit that form, right? What you're describing here is precisely how Rails builds forms, and what it expects to receive when you send your controller the params hash. Now let's say you want to add a select field to your Post to choose a Topic. Post has_one :topic. %= form_for @post do |f| % %= f.collection_select :topic_id, Topic.all, :id, :name, :prompt = true % That gives you: select name=post[topic_id] id=post_topic_id size=1 option value=Please choose.../option option value=42Life, the Universe, and Everything/option ... If you wanted to pick a favorite color from an array, you could do that like this: %= f.collection_select :favorite_color %W(red green blue), :to_s, :titleize, :prompt = true % That gives you: select name=post[favorite_color] id=post_favorite_color size=1 option value=Please choose.../option option value=redRed/option ... In either case, when you create or update a Post, you send the hash params[:post] to its ccontroller, and all the parameters nested inside of that hash are untwisted in there and assigned to the object. It's really very flexible. Walter But don't the arguments change if you call: f.collection_select() ??? -- 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-talk@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 secure file access using Carrierwave + S3 hosted on Heroku
My site is hosted on Heroku and I am using Carrierwave to upload files to Amazon. How can i restrict file access based on roles? Is this possible? Using Devise and CanCan. -- 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 options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: f.collection_select: what are the parameters?
Walter Davis wrote in post #1016097: On Aug 10, 2011, at 9:53 PM, 7stud -- wrote: Hi, Thanks for the response. option And even that isn't entirely correct. Apparently, the name of the select has to be of the form: an_existing_model[:an_existing_field_name_in_that_model] which doesn't make any sense to me. I'm not sure why that is -- you're inside of a form builder, building a form for an object that you plan to modify when you submit that form, right? Why should I have to assume that? Why can't the form select with all the users and their ids, and then the action that the form is submitted to sends a birthday email to the selected user? Or is that what form_for(@user) locks me into? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: How can I update a div value using Ajax but calling a function on the OnChange?
In this code: function load_part_price_select(id, value) { // alert(id); // alert(value); $('#' + id ).live('change',function() { $.ajax({ url: '/parts/' + value + '/price', type: 'get', context: this, dataType: 'script', success: function(responseData) { // alert('success: ' + responseData); $(this).nextAll(span.price:first).html(responseData); } }); }); }; ...why do you have: dataType: 'script', I doubt your action is responding to the ajax request by sending a string with js code in it back to your page--because your action looks like this: def retrieve_part_price @price = Part.find(params[:id]) respond_to do |format| format.html { redirect_to(items_path)} format.js { render :nothing = true } end end It looks like you are trying to send a price back, so you should specify: dataType: 'text' But then I don't understand how your action returns anything because you wrote this: format.js { render :nothing = true } I think that should be render :text. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: javascript_include_tag error
Chris M. wrote in post #1016050: If you put the first argument to javascript_include_tag on the same line (i.e. combine lines 6 and 7), then Ruby will know you're listing arguments to javascrip_include_tag, and it'll work. Thanks. That means I can do this: %= javascript_include_tag( http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js;, jquery.rails.js) % -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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: Sqlite 3 install error on Heroku, Rails 3.1
if using Rails 3.1 add gem 'pg', :group = :production gem 'pg', :group = [:development, :test] into gemfile -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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 does force_ssl works (Rails 3.1)
how does force_ssl inside a controller works, it just work for the current controller actions? becouse I place force_ssl inside my sessions controller and everytime I access to any action of it I start navigating throw https on my whole page not only inside sessions controller. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-talk@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.