[Rails] Nested form with a N-N relation and a predefined list of elements to choose
Hi, I recently had to deal with nested form, and I found quite complex to handle it with my situation. I have a list of choices and want to allow the user to use some from a predefined list, by using checkboxes. I posted the question on Stack Overflow a few days ago, but nobody answered yet. So, to not duplicate the text, here is the link: http://stackoverflow.com/questions/3622312/how-to-write-properly-a-nested-form-with-a-n-n-relation Regards, B.D. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] [newbie question]how to add a new view to a exist controller?
hello everybody , I am a newbie to Rails' world. I just start reading the book Agile web Development with rails one question. How can I add a new view to a exist controller? we can use code: rails generate controller controller_1_name [view_1_name view_2_name] however. if I wanna add a view_3 to controller_1, how can I do with a single line command? I have tried two ways First: rails generate controller controller_1_name view_3_name conflict Second rails generate controller controller_1_name [view_1_name view_2_name view_3_name] still conflict Does anyone have a solution? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Pass selected value in combo as a parameter
On 3 September 2010 11:35, Alfredo Bonilla li...@ruby-forum.com wrote: Hi, I have a select in my form: %= select @issue_type, name, @issue_types.collect {|p| [p.name, p.id]} % What I need to do is execute a method passing the value selected in the combo. I've tried lot of things, but I couldn't. Where are you trying to execute the method? In the browser or in the server? If in the browser then you will have to use javascript (in which case it is not really a Rails question), if in the server then put the select in a form and the selected value will be passed in params when the form is submitted. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Objects with versions: how to avoid 1 + n queries?
On Friday 03 September 2010, Marnen Laibow-Koser wrote: Marnen Laibow-Koser wrote: Well, you learn something new every day! I found the Ambiguous Groups article on the Web and found that the behavior I thought was standard -- returning the first value in the case of multiple values -- is actually a MySQL quirk (ironic when you consider that I haven't used MySQL in years). Back to the drawing board. I did tell you that you ought to understand a problem before jumping to solutions, didn't I? I have to admit I was piqued by your reaction to my original question: it was bold -- and ignorant. You don't have to answer every question in this mailing list single-handedly. Anyway, I'm still looking for a way to express the existing, working SQL solutions (sub-select for the latest version corresponding to an article) in elegant ActiveRecord code. Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Trying to create a collection to use for a report
I have a database of people that have used a local foodbank. The problem I'm having now is that i need a way to put 2 collections into one variable, like rails does it for partials. I want a variable @oxford that does a Household.find_all_by_zip('01540'). This is no problem. The trouble comes when I try to combine lists of new families and returning families to feed the partials properly.. What I have is a main page monthly.erb oxford families render partial = 'monthly_report', :collection = @oxford _monthly_report.erb new families render partial = 'monthly_graph, :collection = monthly_report.new returning families render partial = 'monthly_graph, :collection = monthly_report.returning Rails doesn't seem to like these two areas in the monthly_report variable without being setup, so I hope there is a way to do this. I'm hoping there is a way to set your collections the way you want to do a report. Please help me with the proper way to set this variable up Bob bsm...@gmail.com -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: Objects with versions: how to avoid 1 + n queries?
On 4 September 2010 09:14, Michael Schuerig mich...@schuerig.de wrote: On Friday 03 September 2010, Marnen Laibow-Koser wrote: Marnen Laibow-Koser wrote: Well, you learn something new every day! I found the Ambiguous Groups article on the Web and found that the behavior I thought was standard -- returning the first value in the case of multiple values -- is actually a MySQL quirk (ironic when you consider that I haven't used MySQL in years). Back to the drawing board. I did tell you that you ought to understand a problem before jumping to solutions, didn't I? I have to admit I was piqued by your reaction to my original question: it was bold -- and ignorant. You don't have to answer every question in this mailing list single-handedly. I think that antagonising those trying to help will not enamour you to others reading your question. There is nothing wrong with being bold when answering questions and no-one knows everything. To suggest that someone is ignorant because they are unaware of that particular mysql quirk is absolutely ludricrous. By using the definition of ignorant as 'not knowing absolutely everything' you must include yourself or you would not have to come here to ask your question in the first place. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] File not found: lib when installing rails-3.0.0
I got the following error when try to install rails-3.0.0 on my Ubuntu box. Can anybody help? dw...@dwang-bj-ws:~/Projects$ sudo gem install rails Successfully installed rails-3.0.0 1 gem installed Installing ri documentation for rails-3.0.0... File not found: lib dw...@dwang-bj-ws:~/Projects$ sudo gem install rails Successfully installed rails-3.0.0 1 gem installed Installing ri documentation for rails-3.0.0... File not found: lib dw...@dwang-bj-ws:~/Projects$ ruby gem ruby: No such file or directory -- gem (LoadError) dw...@dwang-bj-ws:~/Projects$ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /usr/lib/ruby/gems/1.8 - /home/dwang/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources = true - :verbose = true - :benchmark = false - :backtrace = false - :bulk_threshold = 1000 - REMOTE SOURCES: - http://rubygems.org/ dw...@dwang-bj-ws:~/Projects$ -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Objects with versions: how to avoid 1 + n queries?
On Saturday 04 September 2010, Colin Law wrote: On 4 September 2010 09:14, Michael Schuerig mich...@schuerig.de wrote: On Friday 03 September 2010, Marnen Laibow-Koser wrote: Marnen Laibow-Koser wrote: Well, you learn something new every day! I found the Ambiguous Groups article on the Web and found that the behavior I thought was standard -- returning the first value in the case of multiple values -- is actually a MySQL quirk (ironic when you consider that I haven't used MySQL in years). Back to the drawing board. I did tell you that you ought to understand a problem before jumping to solutions, didn't I? I have to admit I was piqued by your reaction to my original question: it was bold -- and ignorant. You don't have to answer every question in this mailing list single-handedly. I think that antagonising those trying to help will not enamour you to others reading your question. There is nothing wrong with being bold when answering questions and no-one knows everything. You are right in general, but not in every particular case. I'd like to claim that this particular case does not fit. Re-read the discussion an judge for yourself. I may not like to be told that my code is smelly and my design design is broken by someone who clearly does not understand the setting -- but then, who does like such a thing? It's great to have around people who are trying to be helpful. It's event better, if they go about it without patronizing those who ask. To suggest that someone is ignorant because they are unaware of that particular mysql quirk is absolutely ludricrous. You're getting it wrong. I wouldn't expect anybody to know about exactly how MySQL's implementation of GROUP BY behaves. MySQL allows grouping expressions that are not allowed by the SQL standard and it behaves in predictable ways when using them. This has nothing to do with my question, though, as it doesn't involve MySQL in any way. Now, if someone *does* know about MySQL's specific behaviour and take it for standard, they might be tempted to base a solution on that. Still, as I said more than once, I know what I want to do at the SQL/database level. I don't see how to express it elegantly in ActiveRecord. Michael -- Michael Schuerig mailto:mich...@schuerig.de http://www.schuerig.de/michael/ -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how to add a new view to a exist controller?
On Sep 4, 5:16 am, John Anderson jno...@gmail.com wrote: hello everybody , I am a newbie to Rails' world. I just start reading the book Agile web Development with rails one question. How can I add a new view to a exist controller? we can use code: rails generate controller controller_1_name [view_1_name view_2_name] however. if I wanna add a view_3 to controller_1, how can I do with a single line command? could you not just create app/views/controller_1/view_3.html.erb? Fred I have tried two ways First: rails generate controller controller_1_name view_3_name conflict Second rails generate controller controller_1_name [view_1_name view_2_name view_3_name] still conflict Does anyone have a solution? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Trying to create a collection to use for a report
On Sep 4, 9:18 am, Bob Smith bsm...@gmail.com wrote: I have a database of people that have used a local foodbank. The problem I'm having now is that i need a way to put 2 collections into one variable, like rails does it for partials. I want a variable @oxford that does a Household.find_all_by_zip('01540'). This is no problem. The trouble comes when I try to combine lists of new families and returning families to feed the partials properly.. What I have is a main page monthly.erb oxford families render partial = 'monthly_report', :collection = @oxford _monthly_report.erb new families render partial = 'monthly_graph, :collection = monthly_report.new returning families render partial = 'monthly_graph, :collection = monthly_report.returning Rails doesn't seem to like these two areas in the monthly_report variable without being setup, so I hope there is a way to do this. I'm hoping there is a way to set your collections the way you want to do a report. Please help me with the proper way to set this variable up What do you mean by doesn't seem to like? What do the new returning methods return ? Fred Bob bsm...@gmail.com -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rake background task can not run
On Sep 4, 5:38 am, boblu bobl...@gmail.com wrote: I want to use rake background task in rails like this system(cd #{Rails.root} RAILS_ENV=#{Rails.env} rake abc:def -- trace 21 #{Rails.root}/log/rake.log ) This is ok in development environment, but will not work in production mode. What happens? Fred I used logger to check whether the command string is generated ok or not, but it seems every things is fine in production evironment: cd /home/username/rails_staging/Abc/releases/20100904034630 RAILS_ENV=production rake abc:def --trace 21 /home/username/ rails_staging/Abc/releases/20100904034630/log/rake.log Any body has any ideas about why this can not work in production mode? Thanks -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActiveRecord Find with associations
Ar Chron wrote: Pito Salas wrote: Here's an example: class LineItem ActiveRecord::Base belongs_to :order end class Order ActiveRecord::Base has_many :line_items end my_line_item = LineItem.find(:zipcode = 12345) Order.find_by_line_item(my_line_item) # doesn't work Order.find_by_line_item_id (my_line_item) # does work Probably not explaining this clearly enough (I blame the distillery masters at Lagavulin), but: Wish I was there! Which of their Beer is available in the US? find_by_line_item fails - my_line_item is an instance of the class (an object) that does not have a 'line_item' attribute you indicated, it *is* a LineItem It kind of does, in that Order has_many :line_items, no? And so that's an ActiveRecord method on Order called line_items? By the way, my_order.find_by_line_item fails with no such method, not just by returning []. I wonder if my_order.find_by_line_items would work? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how to add a new view to a exist controller?
Thank you for replying. Yes. I can just create a view_3.html.erb and add a new definition for view_3 as def view_3 # some code end Is there no way to create all of them just by enter single line command ? Maybe in Rails 4 :D ? On Sep 4, 5:31 pm, Frederick Cheung frederick.che...@gmail.com wrote: On Sep 4, 5:16 am, John Anderson jno...@gmail.com wrote: hello everybody , I am a newbie to Rails' world. I just start reading the book Agile web Development with rails one question. How can I add a new view to a exist controller? we can use code: rails generate controller controller_1_name [view_1_name view_2_name] however. if I wanna add a view_3 to controller_1, how can I do with a single line command? could you not just create app/views/controller_1/view_3.html.erb? Fred I have tried two ways First: rails generate controller controller_1_name view_3_name conflict Second rails generate controller controller_1_name [view_1_name view_2_name view_3_name] still conflict Does anyone have a solution? -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActiveRecord Find with associations
Probably not explaining this clearly enough (I blame the distillery masters at Lagavulin), but: Wish I was there! Which of their Beer is available in the US? Lol, Lagavulin is a famous WHISKY destillery By the way, my_order.find_by_line_item fails with no such method, not just by returning []. ActiveRecord knows that your line_item belongs to an order. So it's as easy as: my_line_item.Order -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] its easy but i forgot all
my models borrower- has_many :loans loan -belongs_to :borrower my loans _controller def new @borrower = Borrower.find(params[:borrower_id]) logger.debug ' @borrower.id' logger.debug @borrower.id @loan = Loan.new respond_to do |format| format.html # new.html.erb format.xml { render :xml = @loan } end end def create logger.debug ' @borrower.id' logger.debug @borrower.id @loan = Loan.new(params[:loan]) respond_to do |format| if @loan.save format.html { redirect_to(@loan, :notice = 'Loan was successfully created.') } format.xml { render :xml = @loan, :status = :created, :location = @loan } else format.html { render :action = new } format.xml { render :xml = @loan.errors, :status = :unprocessable_entity } end end end in my views i am passing value like this %= link_to 'New Loan', :controller = 'loans', :action = 'new', :borrower_id = @borrower.id % every thing working fine in Action new logger.debug @borrower.id Gives id but on create it does not shows anything Where i am wrong and did something i missed i wanna save @borrower.id in @loans.borrower_id Please help thanks in advance -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] 2.3.5 guide
On 3 September 2010 18:21, Philip Hallstrom phi...@pjkh.com wrote: It seems the guide at http://guides.rubyonrails.org/ has been updated to 3.0. I am still using 2.3.5 with plans of upgrading. Any ideas on how I can get the older guide? http://guides.rubyonrails.org/v2.3.8/ It would help if there were a link to this from the guides home page. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Using ActiveRecord Find with associations
As I am sure you know the 'find_by*' methods are all dynamic. They are based on the field/column name, not on the type of object the column is supposed to reference (if any). AR will do the magic of finding the ID value if you pass an object to the method but apparently it will not be magic enough to let you remove the '_id' suffix from the field/column name in your 'find_by*' method name. It would be nice if the Rails guys made a little change so we could do what you wanted to do here, though. ;) On Sep 3, 8:27 pm, Pito Salas li...@ruby-forum.com wrote: Here's an example: class LineItem ActiveRecord::Base belongs_to :order end class Order ActiveRecord::Base has_many :line_items end my_line_item = LineItem.find(:zipcode = 12345) Order.find_by_line_item(my_line_item) # doesn't work Order.find_by_line_item_id (my_line_item) # does work I was surprised by this, because it seems to force me to make reference to the id field of the line item, rather than referring to the LineItem as a class or type in the Order.findxxx statement. Am I misunderstanding something or missing a trick? Thanks!! -- Pito -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Triggering Javascript from a Ruby form
I think one of the things you might need is a 'timer', which will let your code 'sleep' before calling again your 'how_finished' function. I have never done this but remember reading about it, I googled for 'javascript sleep timer' and one of the links I found was this: http://www.daniweb.com/forums/thread47199.html In order to communicate with the server from Javascript I would look into Prototype or jQuery. They simplify enormously the code in Javascript to be able to communicate with your server using AJAX. I hope this gets you started. On Sep 3, 8:14 pm, A. Leek li...@ruby-forum.com wrote: Hello again, I've managed to hack together an uploader, but I need a progress bar to go with it. I ended up using FTP to upload, and got a way to find the progress while it's uploading. I split that off into another function in the controller, which is all well and good. The problem is that I need to repeatedly call the how_finished function while the file is uploading. The form goes to the uploading function, so I need another way to repeatedly call how_finished. The best way seems to be with Javascript and AJAX, but I can't find a good way of setting up and calling a Javascript function to get the information from the controller. Looking at other Ruby progress bars (http://railsillustrated.com/screencast-file-uploads-progress-in-rails...) it seems to be possible to call the controller with Javascript, but that also requires a separate module for Apache that doesn't work for FTP uploads. I've been looking around at JSON, but I don't really understand it or how to use it to do what I want. I'm pretty sure I have all the information I need in the program, the problem is getting it all together and I'm not sure if that's even possible. Does anyone have ideas? -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Using ActiveRecord Find with associations
On 4 September 2010 01:27, Pito Salas li...@ruby-forum.com wrote: Here's an example: class LineItem ActiveRecord::Base belongs_to :order end class Order ActiveRecord::Base has_many :line_items end my_line_item = LineItem.find(:zipcode = 12345) Order.find_by_line_item(my_line_item) # doesn't work Order.find_by_line_item_id (my_line_item) # does work I was surprised by this, because it seems to force me to make reference to the id field of the line item, rather than referring to the LineItem as a class or type in the Order.findxxx statement. Am I misunderstanding something or missing a trick? I think you are missing a trick. Once you have my_line_item, to get the item's order just do my_line_item.order There is no need to use find at all. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Dynamic Filters with AJAX (like Redmine/Trac)
Hello Guys, I have a model Person with lots of columns (date, int, string, so on) and right now I need to make a filter for my costumer. My goal is something like this: http://www.redmine.org/projects/redmine/issues. Or, even better: http://trac.edgewall.org/demo-0.12/query. The most interesting feature for me is to be able to choose different columns and to have customized options (LIKE or NOT LIKE for strings, BETWEEN .. and .. for dates, and so on) Unfortunately, Redmine only allows 1 criteria per database column. Trac, on the other hand, accepts OR and AND, so I can make complexes searches, like: something AND something AND something OR something else AND something else That said, my questions are: - Does anybody know anything (Gem, plugin or tutorial) that can help me on the backend or on the frontend? I am using jQuery and Rails 3. - Is the new ActiveRecord Query API on Rails 3 complete enough to make this in a DRY way or should I use a specific Gem for searching (eg. searchlogic)? - Is there any opensource Rails project with such a complete filter like Trac? - Should I try to release it as a Gem when its done? :D Thanks in advance and please excuse my poor English :P -- Fernando Brito -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Upload file attachment with rest or xml
I'll see if I can help. Can you explain what you want to see happen that's not? What do the logs tell us? If you're able to make this work in some situations, compare the log output to a failed request and see if the differences give us any clues. Luke On Sep 2, 10:55 pm, Rodrigo Dominguez li...@ruby-forum.com wrote: BTW, the code I had for the rails code is pretty simple http://pastie.org/1135382 I'm just looking the way to upload a file by using a third party application (I'm trying to provide an api to customers) Thank you -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: rails 2 or ralis 3, which is better for a new project in real life?
On Sep 3, 2010, at 7:27 PM, Philip Hallstrom wrote: On Sep 3, 2010, at 3:44 PM, Cuz Ican wrote: On Sep 3, 2010, at 6:00 AM, 侯健 wrote: Hi, Our team decided to use rails to develop our new web application project. Some of our team members think we should ues rails 3 for our new application, beacuse they have many great new features. But the others doesn't agree with that, they said: There has been many applications based on rails2. Rails 3 are too new to use for a real project. It may have unknown bugs, and we can not get support as easy/quickly as rails 2. All of us agree that we should be based on ruby 1.9, because it is much better than the old versions. Please help up make a desition, rails 2 or ralis 3, which is better for a new project in real life? -- James H. It all depends on what the app is going to do/use.. You are definitely right thinking you will have faster more stable success using rails2. That is not a rails thing but anyone in technology long enough knows this tradeoff no matter the platform. (java, .net, python, drupal, etc..) The bigger slow downs/bugs/time lags tend to be around the plugins/ gems. It takes time to get those all working properly. Everyone wants to be on the newest version but think about servers also. If you keep upgrading your servers a lot of software will break. You can't go install redhat 6 as soon as it is released and think your not going to run into issues. Also think about how many bug fixes and service packs come out after new things arrive. You need to be careful in your decision. What I have learned in all my experience is don't be bleeding edge unless you got it like that and/or want it like that. It seldom is the 'logically smarter' choice for the majority of scenarios. +1 One thing that might change this thinking (for me anyway) is the launch date for the project. If it's in a month or two, I'd stick with 2.x because I don't have the time to deal with plugin/gem issues. If it's 6 months or a year from now, I'd be much more likely to deal with those issues because come launch time 3.x will have had all those things worked out. A timeline of that duration would also give me the time (or let me plan for it) to *help* fix those plugin/gem issues and contribute back. -philip I'm going to tell you to go with Rails3 and Ruby1.9.2 and explain my opinion. Rails3 went beta the first week of February 2010. I was just starting a project with a new client and we figured that going with Rails3.beta was the way to go because it would be final before the project was delivered. At that time, we were wrong. After less than a week, we retreated to 2.3.5 because there were so many little problems with rails and with bundler (and actually more with bundler than rails). (We were using ruby1.8.7) That was 6 months ago. In July 2010, another client started a project. Rails was now 3.0.0.beta4 and starting was much smoother. There were still places where changes from 2.x and documentation that was playing a bit of catch-up to the code gave us fits, but those were manageable. Have there been problems? Yes, but relatively minor (although we did submit a patch for a bug in ruby's CSV standard library). Rails3 forced a decision between ruby-1.8.7 and ruby-1.9.2-something (because it wasn't stable with 1.9.1) and we were at 1.9.2-r23238 (yes, a particular revision in ruby's SVN repository). Now we have an official Rails-3.0.0 release, Ruby-1.9.2-p0 release and gems that are quickly catching up. Seriously, the biggest issue with gems has simply been deprecation warnings -- they have worked fine. There are *significant* differences in ActiveRecord between 2.x and 3.0 and routing has been completely overhauled, too. If you don't already have Rails2 projects, then you'll have to learn how Rails2 does things and then have to re-learn how Rails3 does the same things (because you *will* want to upgrade). The documentation will catch up. The Rails guides are good and there has been over 6 months of beta/rc time for a lot of issues to be baked out of the final release. Any gem maintainers who may have been waiting for an official release no longer has to wait to put the final polish on their gems to make them ready for ruby-1.9.2 or to work seamlessly with rails-3.0.0. Anyone starting a new project right now should definitely be using Rails-3 and Ruby-1.9.2 (or perhaps 1.8.7 if you're limited by your hosting environment, but if you don't have either 1.8.7 or 1.9.2 available then you maybe you need to find a new hosting provider). -Rob Rob Biedenharn r...@agileconsultingllc.com http://AgileConsultingLLC.com/ r...@gaslightsoftware.com http://GaslightSoftware.com/ -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email
[Rails] CSRF protection not working with jquery ajax post request
Hallo, I want to test the csrf protection of my application but forgery protection is not working with jquery ajax request. I have used Unobtrusive Javascript with jquery I have removed the %= csrf_meta_tag % so that my application do not include authenticity token. In my view I have the following code $(function () { $('#alert').click(function () { $.ajax({ type: POST, data: ({ lo: 67, pi: 22 }), url: '/test/set', }); }) }); I have also include in the application controller protect_from_forgery and have set in development configuration config.action_controller.consider_all_requests_local = false However the post command is completed successfully. Does anyone know why the protection is not working? Thank you -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Store a single variable / row in database
What would be the best way in rails to store a single variable and have it persist. Like a have a variable that says total_visits that counts the total number of page loads. The only solution I can think of is having a table with a single row. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Cannot seem to display Comments on User Show Page
Hello, I have added a comment form to my article show page, but after I submit the comment, I get the following error: Couldn't find Article without an ID. I think it is because the Comments controller does not know which article to add the new comment. comments_controller: def create @article = Article.find(params[:article_id]) @comment = @article.comments.create(params[:comment]) if @comment.save flash[:success] = Comment saved. redirect_to articles_path(@article) else render 'show' end end article show page: % @article.comments.each do |comment| % %= comment.title % %= comment.content % %= comment.user % % end % %= form_for([...@article, @article.comments.build]) do |f| % %= render 'shared/error_messages', :object = f.object % div class=field %= f.label :title %br / %= f.text_field :title % /div div class=field %= f.label :content %br / %= f.text_area :content % /div div class=actions %= f.submit Post Comment % /div % end % I am trying to follow this guide: http://edgeguides.rubyonrails.org/getting_started.html#adding-a-second-model 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Cannot seem to display Comments on User Show Page
It would help to know the URL your being redirected to... but I see one potential issue: if @comment.save flash[:success] = Comment saved. redirect_to articles_path(@article) else render 'show' end Lets pretened your comment failed to save... your rendering show... Show what? By default your going to render the comment#show action with no ID. You want to be rendering articles/show i assume. On Sep 4, 1:48 pm, Kelp Kelp li...@ruby-forum.com wrote: Hello, I have added a comment form to my article show page, but after I submit the comment, I get the following error: Couldn't find Article without an ID. I think it is because the Comments controller does not know which article to add the new comment. comments_controller: def create @article = Article.find(params[:article_id]) @comment = @article.comments.create(params[:comment]) if @comment.save flash[:success] = Comment saved. redirect_to articles_path(@article) else render 'show' end end article show page: % @article.comments.each do |comment| % %= comment.title % %= comment.content % %= comment.user % % end % %= form_for([...@article, @article.comments.build]) do |f| % %= render 'shared/error_messages', :object = f.object % div class=field %= f.label :title %br / %= f.text_field :title % /div div class=field %= f.label :content %br / %= f.text_area :content % /div div class=actions %= f.submit Post Comment % /div % end % I am trying to follow this guide:http://edgeguides.rubyonrails.org/getting_started.html#adding-a-secon... Thanks. -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] What does mean in a sql query?
This is from the rails log: SELECT district_sets.id FROM district_sets WHERE (district_sets.ident = 'juris-60c8bcea56c0dfa02d121691e0e72152' AND district_sets.id 12) LIMIT 1 I am confused by the operator. Can anyone clarify that for me please? Thanks! -- Pito -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Store a single variable / row in database
IMHO The biggest problem with rails is the fact that it makes working easy and fun as long as your work can follow the MVC system. If you try to do it your way it won't be the rails way (at least as far as I know). If you want to track any more information other then number of pages views, create a page_view model and give it some logic to do the rest of your magic. If you want to track views of a specific model, add a page_views field to that model. If you just want to track the number of page views on your entire website use an analytics program :) Brian On Sep 4, 1:26 pm, Shea Barton li...@ruby-forum.com wrote: What would be the best way in rails to store a single variable and have it persist. Like a have a variable that says total_visits that counts the total number of page loads. The only solution I can think of is having a table with a single row. -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: What does mean in a sql query?
http://dev.mysql.com/doc/refman/5.0/en/non-typed-operators.html not equals On Sep 4, 2:06 pm, Pito Salas li...@ruby-forum.com wrote: This is from the rails log: SELECT district_sets.id FROM district_sets WHERE (district_sets.ident = 'juris-60c8bcea56c0dfa02d121691e0e72152' AND district_sets.id 12) LIMIT 1 I am confused by the operator. Can anyone clarify that for me please? Thanks! -- Pito -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: What does mean in a sql query?
!= -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: File not found: lib when installing rails-3.0.0
I can verify this on ubuntu using those specs. I installed rails 3 using ruby 1.9.2 and RVM. I suggest that as well. http://rvm.beginrescueend.com/ There is a railscsts on rvm as well. Brian On Sep 4, 4:36 am, Dongsheng Wang li...@ruby-forum.com wrote: I got the following error when try to install rails-3.0.0 on my Ubuntu box. Can anybody help? dw...@dwang-bj-ws:~/Projects$ sudo gem install rails Successfully installed rails-3.0.0 1 gem installed Installing ri documentation for rails-3.0.0... File not found: lib dw...@dwang-bj-ws:~/Projects$ sudo gem install rails Successfully installed rails-3.0.0 1 gem installed Installing ri documentation for rails-3.0.0... File not found: lib dw...@dwang-bj-ws:~/Projects$ ruby gem ruby: No such file or directory -- gem (LoadError) dw...@dwang-bj-ws:~/Projects$ gem env RubyGems Environment: - RUBYGEMS VERSION: 1.3.7 - RUBY VERSION: 1.8.7 (2010-01-10 patchlevel 249) [x86_64-linux] - INSTALLATION DIRECTORY: /usr/lib/ruby/gems/1.8 - RUBY EXECUTABLE: /usr/bin/ruby1.8 - EXECUTABLE DIRECTORY: /usr/bin - RUBYGEMS PLATFORMS: - ruby - x86_64-linux - GEM PATHS: - /usr/lib/ruby/gems/1.8 - /home/dwang/.gem/ruby/1.8 - GEM CONFIGURATION: - :update_sources = true - :verbose = true - :benchmark = false - :backtrace = false - :bulk_threshold = 1000 - REMOTE SOURCES: -http://rubygems.org/ dw...@dwang-bj-ws:~/Projects$ -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rake background task can not run
My first suspicion would be that you need the full path to rake but no promises :) On Sep 4, 5:36 am, Frederick Cheung frederick.che...@gmail.com wrote: On Sep 4, 5:38 am, boblu bobl...@gmail.com wrote: I want to use rake background task in rails like this system(cd #{Rails.root} RAILS_ENV=#{Rails.env} rake abc:def -- trace 21 #{Rails.root}/log/rake.log ) This is ok in development environment, but will not work in production mode. What happens? Fred I used logger to check whether the command string is generated ok or not, but it seems every things is fine in production evironment: cd /home/username/rails_staging/Abc/releases/20100904034630 RAILS_ENV=production rake abc:def --trace 21 /home/username/ rails_staging/Abc/releases/20100904034630/log/rake.log Any body has any ideas about why this can not work in production mode? Thanks -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Nothing is being inserted into the database...help!
Hello all, for some reason nothing is being inserted into the database. I have no idea why not! Here is my action: def create @information = CalorieKing.new @information = CalorieKing.get_information(params[:id]) @information = @information['food']['servings'] @information['serving'].each do |s| if s['name'] == params[:portion_type] s['nutrients'].each do |value| value *= params[:size] end puts 'hello' @foodentry = FoodEntry.new(:user_id = current_user.id, :name = s['name'], :serving_size = params[:size], :serving_name = params[:portion_type], :calories = s['nutrients']['caloires'], :fat = s['nutrients']['fat'], :carbs = s['nutrients']['carb'], :protein = s['nutrients']['protein'], :fiber = s['nutrients']['fiber'], :sugar = s['nutrients']['sugar'], :sodium = s['nutrients']['sodium'], :calcium = s['nutrients']['calcium'], :satfat = s['nutrients']['satfat'], :cholesterol = s['nutrients']['cholesterol']) @foodentry.save puts 'hello' end end respond_to do |format| format.html { redirect_to(food_diary_path) } format.xml { head :ok } end end 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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: YM4R - convert variable to string error
I had the same problem. In mapping.rb of the plugin, add this function to class Variable def to_str @variable + ; end Appears to work fine after this fix. Dave -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: What does mean in a sql query?
Fernando Perez wrote: != Thanks... The reason I didn't think that is what it meant (although I believe you :) is that I saw it here: [Development] ap j #DistrictSet:0x105568550 { :id = 3, :display_name = ds2, :created_at = Sat, 04 Sep 2010 11:21:36 PDT -07:00, :updated_at = Sat, 04 Sep 2010 11:21:36 PDT -07:00, :secondary_name = nil, :icon_file_name = nil, :icon_content_type = nil, :icon_file_size = nil, :icon_updated_at = nil, :descriptive_text = nil, :ident = juris-a88e89de29712642eaef324fd9bc03ed } = nil ## in other words, j is assigned a DistrictSet object, that has j.id = 3 [Development] j.save! DistrictSet Load (0.3ms) SELECT district_sets.id FROM district_sets WHERE (district_sets.ident = 'juris-a88e89de29712642eaef324fd9bc03ed' AND district_sets.id 3) LIMIT 1 [paperclip] Saving attachments. = true ## And when I ask activerecord to save it, I see the very odd 3. Do you understand what it means? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Re: What does mean in a sql query?
On 4 September 2010 20:49, Pito Salas li...@ruby-forum.com wrote: Fernando Perez wrote: != Thanks... The reason I didn't think that is what it meant (although I believe you :) is that I saw it here: [Development] ap j #DistrictSet:0x105568550 { :id = 3, :display_name = ds2, :created_at = Sat, 04 Sep 2010 11:21:36 PDT -07:00, :updated_at = Sat, 04 Sep 2010 11:21:36 PDT -07:00, :secondary_name = nil, :icon_file_name = nil, :icon_content_type = nil, :icon_file_size = nil, :icon_updated_at = nil, :descriptive_text = nil, :ident = juris-a88e89de29712642eaef324fd9bc03ed } = nil ## in other words, j is assigned a DistrictSet object, that has j.id = 3 [Development] j.save! DistrictSet Load (0.3ms) SELECT district_sets.id FROM district_sets WHERE (district_sets.ident = 'juris-a88e89de29712642eaef324fd9bc03ed' AND district_sets.id 3) LIMIT 1 [paperclip] Saving attachments. = true ## And when I ask activerecord to save it, I see the very odd 3. Do you understand what it means? I may be wrong but have you got a validates_uniqueness_of on ident? That query could be checking to see if there is already a matching ident. The id3 could be so that it does not find the one you are updating or creating. Colin -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Pass a value from controller to model
I'm trying to pass a value from a cookie from the controller into model by using attr_accessor. But it doesn't work and I suspect I do something wrong. Is this on the right path? class Test ActiveRecord::Base attr_accessor :key key .. end class TestController ApplicationController def new @test = Test.new @test.key = cookies[:my_key] end end -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] about routes
Hello everyone, I'm trying to map a controller actions with the name as a action. I've got it well: match /home = main#home, :as = :home match /contact = main#contact, :as = :contact match /whoweare = main#whoweare, :as = :whoweare But I want to do this with only one line of code. I've tried it with this line, but it don't work: match ':action' = 'main#:action', :as = :action Any idea? Thanks and greetings. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Moving ROR Dev from one windows PC to another
Is it possible to move the complete ROR install/development directory or directories to new PC and continue to work/dev as the original one? Are there any registry entries that would preclude this working on the new PC? Thanks! -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Nothing is being inserted into the database...help!
On 4 Sep, 20:23, Zack Nathan li...@ruby-forum.com wrote: Hello all, for some reason nothing is being inserted into the database. I have no idea why not! Here is my action: Did you check for any validations failing Fred def create @information = CalorieKing.new @information = CalorieKing.get_information(params[:id]) @information = @information['food']['servings'] @information['serving'].each do |s| if s['name'] == params[:portion_type] s['nutrients'].each do |value| value *= params[:size] end puts 'hello' @foodentry = FoodEntry.new(:user_id = current_user.id, :name = s['name'], :serving_size = params[:size], :serving_name = params[:portion_type], :calories = s['nutrients']['caloires'], :fat = s['nutrients']['fat'], :carbs = s['nutrients']['carb'], :protein = s['nutrients']['protein'], :fiber = s['nutrients']['fiber'], :sugar = s['nutrients']['sugar'], :sodium = s['nutrients']['sodium'], :calcium = s['nutrients']['calcium'], :satfat = s['nutrients']['satfat'], :cholesterol = s['nutrients']['cholesterol']) @foodentry.save puts 'hello' end end respond_to do |format| format.html { redirect_to(food_diary_path) } format.xml { head :ok } end end Thanks! -- Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Decimal numbers pain
Hi, What do you guys use to definitely handle decimal numbers? This is getting me crazy! I use BigDecimal, but it craps out of the input number is something like 14,53, Rails transforms it as 14.0 Any solution? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: What does mean in a sql query?
Do you understand what it means? It's probably a validates_uniqueness_of that adds that additional query. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Pass a value from controller to model
It should work. What makes you think it doesn't? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Decimal numbers pain
What do you guys use to definitely handle decimal numbers? This is getting me crazy! I use BigDecimal, but it craps out of the input number is something like 14,53, Rails transforms it as 14.0 Any solution? Are you really using the comma in the data? This IRB session suggests what might be happening (unless there's a en ENV flag that allows the comma?): require 'bigdecimal' = true x = BigDecimal = BigDecimal x = 14.4564 = 14.4564 x = 14,4564 = [14, 4564] -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Nothing is being inserted into the database...help!
for some reason nothing is being inserted into the database. I have no idea why not! Here is my action: The most common cause is that validations are failing, and you're just not seeing that. -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Cannot seem to display Comments on User Show Page
I figured out the problem with the original post, but I have a new problem. When a user submits an invalid comment(if the title or content does not validate correctly), they get sent back to the article. There are two problems, though. 1. The form does not keep the previous field content, so the form resets. 2. All the comments disappear. Articles controller: def show @article = Article.find(params[:id]) @comments = @article.comments.paginate(:page = params[:page]) @title = @article.title end Comments controller: def create @article = Article.find(params[:article_id]) @comment = @article.comments.build(params[:comment]) @comment.user_id = current_user.id if @comment.save flash[:success] = Comment saved. redirect_to @article else flash[:error] = Error in creating comment. render 'articles/show' end end Here's the comment form and the comment display code, if you need it: Comment Form: %= form_for([...@article, @article.comments.build]) do |f| % %= render 'shared/error_messages', :object = f.object % div class=field %= f.label :title %br / %= f.text_field :title % /div div class=field %= f.label :content %br / %= f.text_area :content % /div div class=actions %= f.submit Post Comment % /div % end % shared/_comments.html.erb: % unless @comments.nil? || @comments.empty? % %= render :partial = 'shared/comment', :collection = @comments % %= will_paginate @comments % % end % shared/_comment.html.erb %= comment.title %br / %= comment.content %br / %= comment.user.name %br /br / Thank you. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe 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: Store a single variable / row in database
What would be the best way in rails to store a single variable and have it persist. Like a have a variable that says total_visits that counts the total number of page loads. The only solution I can think of is having a table with a single row. One answer would be yes, pretty much if you really want to store a single data point that's accessible to a number of instances of Rails, then either a file or a database is what you'll need to use (assuming you don't trust anything RAM based). However, your specific scenario could quickly become an extreme bottleneck. It would be better served by logging (preferably asynchronously), and then read tally the log to create your total. Do it periodically, so you're not starting from the first log every every time. There's probably other ways, but using a single var for something like page loads is looking for trouble as your app scales. If you know the page requests will be low enough to not be a bottleneck then using the DB with row or table locking (effectively the same for this case) might be OK. Another option if you can tolerate the potential for a little inaccuracy is to go ahead and use RAM (with a mutex) to keep the count, and periodically write that value to disk to minimize the disk access. If you have load balanced app servers you'll need a central RAM cache like memcache. That's what comes to my mind -- others may have better ideas. -- gw -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Cannot seem to display Comments on User Show Page
You almost have it all correct, just in your view: %= form_for([...@article, @comment]) do |f| % -- http://digiprof.tv -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Nothing is being inserted into the database...help!
And your controller should be put on a diet... -- http://digiprof.tv -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Decimal numbers pain
It seems Rails does it a bit differently. Anyway I was able to find a solution: http://gem-session.com/2010/03/how-to-use-the-comma-as-decimal-separator-in-rails-activerecord-columns-and-text-fields -- http://digiprof.tv -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Authlogic user login and register new user side-by-side
and then rendering a partial of the login form on the 'new' action of users. Am I in the right direction? Yes, simply render a partial for registration on login page or vice-versa. See this example: http://suivauto.com/login -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Store a single variable / row in database
Well, specifically what it would be for is an app which parses / collects stats on twitter. I want to have a persistant of the ID (twitter side) of the most recent parsed tweet, so I know where to start at the next startup, or in case it gets interrupted. I don't what to log every tweet I parse to the database (there are tens of thousands), nor do I need to. So a single-row table would be the best way to do this? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] sqlite3/sqlite3_native (LoadError)
Hi, I have installed ruby 1.9.2, rubygems 1.3.7 and rails 3.0. created a demo application. when I start 'rails server' I get: 'require': no such file to load -- sqlite3/sqlite3_native (LoadError) any idea ? Thank you. Dani -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: about routes
I forgot to say that I'm using Rails 3 and Ruby 1.9.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-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Re: [Rails] Store a single variable / row in database
change your question to how can count the total number of page loads for ? For what? On 4 September 2010 13:26, Shea Barton li...@ruby-forum.com wrote: What would be the best way in rails to store a single variable and have it persist. Like a have a variable that says total_visits that counts the total number of page loads. The only solution I can think of is having a table with a single row. -- 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.comrubyonrails-talk%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Rails friendly Forex broker?
I'm starting a new hobby. Going to learn about and have a try at building some automated trading systems for forex and other markets. So far I've been very disappointed with the results of my googling looking for a broker and/or third-party product to use as a bridge between the software I will build and an actual trading account. Since I already know a bit about Rails, I'm thinking I would like to start there even if it isn't the most obvious platform from which to do this sort of thing. It does, however, provide a familiar set of tools I expect to use such as Ruby and mySQL front end. At the same time, once it gets to that point it can make it easy to create an administrative control panel for my trading activities that would be accessible from anywhere (with a strong password ;) ) Thanks for any hints you can give me on where to find an easy access point to this world from Rails. jp -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Developing a web chat using Rails 3
Hi! I'm trying to develop a web chat (like the facebook one, but much simpler) that works inside Rails 3, and so I'm inquiring about the methods used for this scope. I had some success applying this guide http://www.web2media.net/laktek/2010/02/16/building-real-time-web-apps-with-rails3/ , so now I am able to send messages form the server to the client. Anyway, I read about some sort of XML-based protocol called XMPP, which seems to be widley used in this cases. I really don't know anything about either cramp or XMPP, and so I would ask: * Do you have some info about cramp (guides, explanations, examples...)? apart from the above post, I found this http://m.onkey.org/2010/1/7/introducing-cramp , and nothing else (maybe because it is relatively young?) Above all.. * ... how does cramp work? Is a parallel server? A thread? What is it??? :) * Is XMPP the way? Do you know how to implement it? * Do you know anything about the argument? Every contribute is appreciated! -- 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.