Re: [Rails] installing rails2 with existing rails3
On 26 August 2011 06:33, ashok k. li...@ruby-forum.com wrote: hello all, i am working on rails3 currently... and now i need rails2 as well ..how to install rails2 with existing rails3. i tried using rvm but getting the error as rvm command not found even after installing it... rvm is the way to do it. Make sure you have followed carefully the instructions for installing it, dependent on your operating system. 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] rails consultant available in Boston
I have a project I'm coming off of on September 1st, anyone need help on a project? I'm in Boston, MA but work remotely a lot of the time for people in other places. -Kevin -- 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: Use find with a variable
On Thu, Aug 25, 2011 at 1:18 PM, Leonel *.* li...@ruby-forum.com wrote: This is making me crazy, even if I do... %= a % I get... #Part:0x7f2fe2bf4cf8 But as soon as I try to access the cost or name attributes I get... undefined method `cost' for nil:NilClass and it's NOOT NIIILL!!! :( Can you pastebin your controller / view code? -- 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] Toggle Shipping Address
On Thu, Aug 25, 2011 at 5:34 PM, Allan M allan.mos...@gmail.com wrote: In my application, i am able to hide the shipping address in my view if a checkbox is checked. I want to add some text (paragraph) in the shipping section. I could not figure out how to make this behave like the form. I need this hidden too until the checkbox is marked. Is this possible? You'll probably want to do this in javascript. jQuery being the obvious choice. It's absolutely possible, but it's not at all related to RoR (unless there's some way to get that behavior within the framework, which I'm unaware of). -- 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] Problems with AJAX and bind
I have a list of topics which is loaded as a partial into a div. Each topic has a destroy action and an id. It works great to add topics and also to delete, except that I can't make the loader symbol to stop running. I guess do to the fact that the link, the initializer, of the data-remote action is destroy so it doesn't know when to run 'ajax:success'. How should I deal with this problem? -- 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: Use find with a variable
On Aug 25, 6:18 pm, Leonel *.* li...@ruby-forum.com wrote: This is making me crazy, even if I do... %= a % I get... #Part:0x7f2fe2bf4cf8 But as soon as I try to access the cost or name attributes I get... undefined method `cost' for nil:NilClass Can you post the entirety of what's in your view? Fred and it's NOOT NIIILL!!! :( -- 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] how to convert Date to this json format
Hi I have to create a json date like {startDate:\/Date(1291145744713-0700)\/,endDate:\/Date(1293824144713-0700)\/} This is just an example. My case startdate = Time.now-2.day enddate = Time.now I dont know how to convert this to the above format. Please help 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] Opening classes in tests makes rake gone wild
Hi! I've discovered that when I reopen classes to return another value, everything works fine when launching the test manually but when I use rake test, the value set reopening the class impacts other tests. Do you know why? PS: yeah I know I can use mocha ;) -- 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/-/JdnKnJaOc9oJ. 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 to convert Date to this json format
date_range = {:start_date = (Time.now - 2.days).to_i, :end_date = Time.now.to_i} date_range.to_json will give {\start_date\:1314182763,\end_date\:1314355563} Is this what you want? -- 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] How to safely embed JSON object in HTML document
David, I want to embed it in HTML so that I can just send that one HTML page to user after log in, and no other HTTP requests are needed before the user can start using the app. This is because it would take several small, but slow, HTTP requests to gather all the data that is needed to show the page. I guess I could whip up a special API method that would return all the data in a single HTTP roundtrip, but if I can pull off this JSOPN embedding, then I can skip even that one extra HTTP requests for initial load. After initial load, app will rarely be needing data from the server, and when it does, it will be using regular API to get that data. This is all just a performance optimization, since most of our users are on a high latency network (mobiles), so those HTTP requests really take a while, and this is an attempt to just skip them altogether. Is there no easy way to embed HTML safe JSON in an HTML document, and have it parsed by JavaScript engine at the same time? Thanks, Alex On Fri, Aug 26, 2011 at 2:19 AM, David Chua zhc...@gmail.com wrote: Hi Alex, What is it that you're actually trying to do? I don't think its such a good idea to put a JSON string on the client side as it can be manipulated to no end. Why not just call the JSON object directly from the controller instead? David @davidchua On Fri, Aug 26, 2011 at 1:27 AM, Alex Duck alex2d...@gmail.com wrote: Hi all, I'm working on a Backbone.js single page app with Rails 3.1, and in an attempt to save on HTTP requests, I want to embed initial data set in a HTML document that is sent back to the browser after successful login. I was thinking I can simply convert my ruby object to JSON, then HTML escape resulting string of JSON, and then use that as a value for JavaScript variable. Something like this: % tags = [{name:tag1, color:green}, {name:/scriptbI can do something bad here/b, color:red}] % script type=text/javascript charset=utf-8 //![CDATA[ var tags_list = %= tags.to_json %; // ]] /script However, this escapes all the double quotes in that string, which triggers a SyntaxError: Unexpected token in Chrome: var tags_list = [{quot;namequot;:quot;tag1quot;,quot;colorquot;:quot;greenquot;}, {quot;namequot;:quot;lt;/scriptgt;lt;bgt;I can do something bad herelt;/bgt;quot;,quot;colorquot;:quot;redquot;}]; If I remove the Rails' default HTML escaping with %=raw tags.to_json %, then it returns this: var tags_list = [{name:tag1,color:green},{name:/ scriptbI can do something bad here/b,color:red}]; which, of course, breaks the HTML document with /script. I guess what I really want is to tell to_json() method to HTML escape keys and values inside JSON object(s), instead of it returning the JSON string unescaped, and then having Rails escape that whole string. I guess what I need is something like this: var tags_list = [{name:tag1,color:green},{name:lt;/ scriptgt;lt;bgt;I can do something bad herelt;/ bgt;,color:red}]; I thought about storing JSON string in a script type=application/ json id=json_string tag, and then doing something like $.parseJSON($(#json_string).html()) but that also has the same problem of escaping, like in the above example. Is there any easy (Rails) way to do that? Or am I doing it wrong to begin with? Cheers! -- 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. -- 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 to convert Date to this json format
t = Time.now puts t.strftime(%s%z) format = '{startDate:\/Date(%s)\/}' puts format % [t.strftime(%s%z)] --output:-- 1314356117-0400 {startDate:\/Date(1314356117-0400)\/} -- 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] Prevent Infinite loop in Self-Join Association
Hi, I have such a data base which has a self-join as association. I want to know that is there any good gem available which i can use for self-join in my application? My main intension is to prevent infinite loop in searching the records. @Anand -- 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: Opening classes in tests makes rake gone wild
On Aug 26, 10:57 am, Michel Pigassou dag...@gmail.com wrote: Hi! I've discovered that when I reopen classes to return another value, everything works fine when launching the test manually but when I use rake test, the value set reopening the class impacts other tests. Tests should leave the environment unchanged. That's why (for example) transactions are used so that objects created in one test aren't there when the next test runs. Your test framework doesn't know how to undo whatever you did when you reopened the class, so the change persists. If you absolutely have to do it this way, you'll need to undo the change once the test that needs it is complete. Fred Do you know why? PS: yeah I know I can use mocha ;) -- 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 to safely embed JSON object in HTML document
Alex Duck wrote in post #1018609: Is there no easy way to embed HTML safe JSON in an HTML document, and have it parsed by JavaScript engine at the same time? You could Base64 encode the JSON and decode it on the client-side with JavaScript. I am ABSOLUTELY NOT recommending that you do this, but simply stating that it could work. Still a bad design idea IMHO. -- 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: Problems with AJAX and bind
Solved it: $('a[data-method=delete]').live('ajax:success', function(){ StopLoader() }); -- 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] gem installation issues
hi all, This may seem trivial and stupid to the experts , but i have been at it for over 2 weeks and all answers got from forums did not help with resolving the issue. Even using cygwin didn't help , i get the same errors. I'm working on a windows- rails combination and am trying trying to setup an existing application which uses a plethora of gems. I'm done with about a hundred gems , but 3 gems are failing the installations. I'm listing the gem and the error i recieve below, if anyone has any solution for hese issues , i'll be immensely grateful. 1) gem install rjb Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing rjb: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir . --ruby=C:/RailsInstaller/Ruby1.8.7/bin/ruby extconf.rb:45:in `open': No such file or directory - C:\Program Files\Java\include (Errno::ENOENT) from extconf.rb:45 2) gem install ruby-xslt Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR:Error installing ruby-xslt:ERROR:Failed to build gem native xtension. C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb checking for xmlParseDoc() in -lxml2... no checking for xsltParseStylesheetFile() in -lxslt... no checking for exsltRegisterAll() in -lexslt... no *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary libraries and/or headers. Check the mkmf.log file for more details. You may need configuration options. Provided configuration options: --with-opt-dir . --without-exsltlib extconf.rb:57:in ``': No such file or directory - xml2-config --cflags (Errno::ENOENT) from extconf.rb:57 3) gem install system_timer Temporarily enhancing PATH to include DevKit... Building native extensions. This could take a while... ERROR: Error installing system_timer: ERROR: Failed to build gem native extension. C:/RailsInstaller/Ruby1.8.7/bin/ruby.exe extconf.rb creating Makefile make gcc -I. -I/C/RailsInstaller/Ruby1.8.7/lib/ruby/1.8/i386-mingw32 -I/C/RailsInstal ler/Ruby1.8.7/lib/ruby/1.8/i386-mingw32 -I. -g -O2 -DFD_SETSIZE=256 -c system_timer_native.c system_timer_native.c: In function 'install_first_timer_and_save_original_configuration': system_timer_native.c:43:22: error: storage size of 'timer_interval' isn't known system_timer_native.c:52:26: error: 'SIG_BLOCK' undeclared (first use in this function) system_timer_native.c:52:26: note: each undeclared identifier is reported only once for each function it appears in system_timer_native.c:63:5: error: invalid use of undefined type 'struct sigaction' system_timer_native.c:64:24: error: 'SIGALRM' undeclared (first use in this function) system_timer_native.c:81:24: error: 'ITIMER_REAL' undeclared (first use in this function) system_timer_native.c:95:26: error: 'SIG_UNBLOCK' undeclared (first use in thisfunction) system_timer_native.c: In function 'install_next_timer': system_timer_native.c:108:22: error: storage size of 'timer_interval' isn't known system_timer_native.c:118:26: error: 'SIG_BLOCK' undeclared (first use in this function) system_timer_native.c:129:24: error: 'ITIMER_REAL' undeclared (first use in this function) system_timer_native.c:142:26: error: 'SIG_UNBLOCK' undeclared (first use in this function) system_timer_native.c: In function 'restore_original_configuration': system_timer_native.c:156:26: error: 'SIG_BLOCK' undeclared (first use in this function) system_timer_native.c:167:5: error: invalid use of undefined type 'struct sigaction' system_timer_native.c:169:31: error: 'SIGALRM' undeclared (first use in this function) system_timer_native.c:174:5: error: invalid use of undefined type 'struct sigaction' system_timer_native.c: In function 'restore_original_timer_interval': system_timer_native.c:189:24: error: 'ITIMER_REAL' undeclared (first use in this function) system_timer_native.c: In function 'restore_sigalrm_mask': system_timer_native.c:197:37: error: 'SIGALRM' undeclared (first use in this function) system_timer_native.c:198:21: error: 'SIG_UNBLOCK' undeclared (first use in this function) system_timer_native.c: In function 'init_sigalarm_mask': system_timer_native.c:272:31: error: 'SIGALRM' undeclared (first use in this function) system_timer_native.c: In function 'set_itimerval': system_timer_native.c:292:10: error: dereferencing pointer to incomplete type system_timer_native.c:293:10: error: dereferencing pointer to incomplete type system_timer_native.c:294:10: error: dereferencing pointer to incomplete type make: *** [system_timer_native.o] Error 1 -- Posted via
[Rails] Re: gem installation issues
On Aug 26, 9:27 am, vikram dhillon li...@ruby-forum.com wrote: hi all, This may seem trivial and stupid to the experts , but i have been at it for over 2 weeks and all answers got from forums did not help with resolving the issue. Even using cygwin didn't help , i get the same errors. I'm working on a windows- rails combination and am trying trying to setup an existing application which uses a plethora of gems. I'm done with about a hundred gems , but 3 gems are failing the installations. I'm listing the gem and the error i recieve below, if anyone has any solution for hese issues , i'll be immensely grateful. 1) gem install rjb http://groups.google.com/group/rubyinstaller/msg/94d3213dc18193b0 And the whole thread: http://groups.google.com/group/rubyinstaller/browse_thread/thread/bb57df69742d5100 2) gem install ruby-xslt Same and similar problem than the one before: you need development headers, xslt dependencies which I believe are provided by libxml2 3) gem install system_timer Released system_timer is not prepared to handle timing on Windows. https://github.com/ph7/system-timer/issues/2 There is no official word on including these changes to correct the issue. -- Luis Lavena -- 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: Problem with rails generaterspec:install, Error-Message: no such file to load, sprockets-railtie (loadError)
On Aug 25, 12:21 pm, Anna.Garance anna.gara...@googlemail.com wrote: Hey guys, I'm a RoR-Beginner and I started learning it with the RoR-Tutorial. Actually I'm at this chapter (http://ruby.railstutorial.org/chapters/ static-pages#top) and try to install rspec. But everytime when I try to use rails g rspec:install I get this error message: C:\Sites\rails\rails_projects\sample_appprails g rspec:install C:/Sites/rails/rails_projects/sample_appp/config/application.rb:8:in `require': no such file to load -- sprockets/railtie (LoadError) This might indicate a gem is missing. what gem list sprockets display? Did you ensure your bundle is installed (doing bundle install at the project directory) Has anybody an idea to help me? I already tried to comment it out in the application.rb or to explicitly mention it in the gemfile. But I still get this error message. See above questions, is sprockets gem installed? -- Luis Lavena -- 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: Opening classes in tests makes rake gone wild
I hear you Frederick. But I forgot one detail: my problem is that a class reopen in a test file impacts tests in another test file. I thought rake would reload every class between each test file. -- 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/-/ug3yU8zUT9cJ. 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: How to safely embed JSON object in HTML document
I have no idea why embedded json would be considered worse than the rest of the page that is sent down. I do it all the time, usually with small items though, so I haven't have the problem you are describing. I was hoping that someone would have a suggestion of a built in method to call. I've had to do this in a helper that was constructing a complicated object, and I think this is similar to your problem: 1) enumerate through all the parts of your object that could contain dangerous data and call h() on them. 2) call raw(your_object.to_json) on the result. It's definitely not an easy, generic solution, but it gets you past this problem. On Fri, Aug 26, 2011 at 8:22 AM, Robert Walker li...@ruby-forum.com wrote: Alex Duck wrote in post #1018609: Is there no easy way to embed HTML safe JSON in an HTML document, and have it parsed by JavaScript engine at the same time? You could Base64 encode the JSON and decode it on the client-side with JavaScript. I am ABSOLUTELY NOT recommending that you do this, but simply stating that it could work. Still a bad design idea IMHO. -- 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: How to safely embed JSON object in HTML document
The purpose of JSON is to be able to interchange the data between various systems. As you are not going to do that then why use JSON at all? Honestly if you are going to process the JSON with Javascript what dont you write your data out as Javascript data structures (which it would be converted from JSON anyway) in the page and process that? What do you gain from embedding the JSON then having to convert it into Javascript data structures over just writing the native Javascript data structures? -- 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: Get an object from the encoding reference
On Aug 25, 12:53 pm, Maese klbs.ma...@gmail.com wrote: hi, i have a string with the enconding reference like #MyObject: 0x2b9027de there any way to get the object from the string ? Thanks Tim's method works - but you should REALLY REALLY think about what's causing you to want to do this. This sort of trick could be handy when debugging, but using it in code that's meant to run reliably can wind up giving you some serious headaches. For instance, the object referred to by the string could get garbage-collected before you can dereference it... --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] fragment cache erorr - view 2 times
I have rails 3.0.9 + nginx + memcached + dalli. #production.rb config.cache_store = :dalli_store, Memcache_servers, { :namespace = 'koolinar', :expires_in = 1.day, :compress = true } #app/view/test/test.html.erb % cache do %hello% end % in browser i get hello hello Result is shown twice. Hope you can 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] XML template render problem after upgrade to 3.0.10
Hi, Yesterday, I upgraded from 3.0.3 to 3.0.10. I've encountered a problem with rendering XML. Here's the situation. The app is primarily a non-RESTful API app. Controller actions should respond to requests with an XML response without the need to have an .xml at the end of the route request. For my controller actions I have written a builder (action_name.xml.builder) template and a builder layout (all_responses.xml.builder). For all the actions in the controller, I set the default layout to all_responses using the controller layout class method. Under this scenario, Rails performed as expected in version 3.0.3. I could write the following and the correct XML with layout was produced. def action_name @animal = Animal.new render :content_type = application/xml and return end Rails would find the builder template under the controllers view directory as expected. It would work as well with the following: respond_to do |format| format.xml{render :status = 200} end After upgrading to rails 3.0.10. Rendering is no longer working as expected. Instead, I get the following error: Missing template action_name with {:locale=[:eng, :eng], :formats=[:html], :handlers=[:rjs, :rhtml, :erb, :rxml, :builder]} in view paths /Users/me/src/app_name/app/ views (ActionView::MissingTemplate) In other words, Rails 3.0.10 no longer can find the template. It instead appears to always be searching for the html template which doesn't exist. As a partial fix, I have to specify literally everything. For example def action_name render :template = controller_name/ action_name.xml.builder, :status = 200, :layout = 'all_response.xml.builder' and return end But it only partially fixes the problem. If I go into the debugger, when I'm in this action, and I execute manually the render line above. I receive the correct XML response with the XML from the all_response.xml.builder layout. However, the actual response that Rails 3.0.10 delivers strips XML produced by the builder layout and actually wraps my action_name.xml.builder XML with a HTML doc type and the html tags such as html and body. In other words, despite the fact that I specify manually all the views and layout, it insists on producing HTML. I'm at a lose about what's going on here. I search the Rails change logs and couldn't find anything that seems to affect the way rendering works. If anyone could provide help or advice, I would greatly appreciate it. Chad -- 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: Opening classes in tests makes rake gone wild
On Aug 26, 2:32 pm, Michel Pigassou dag...@gmail.com wrote: I hear you Frederick. But I forgot one detail: my problem is that a class reopen in a test file impacts tests in another test file. I thought rake would reload every class between each test file. As you have discovered, it doesn't (would probably be prohibitively slow) 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: PGError: server closed the connection unexpectedly
Nothing seems to help. Turned off ssl and added it to database.yml Stopped passenger spawning Downgraded pg gem to 0.10.1. Still get the random errors -- 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] Nokogiri gem issues
Hello all, I recently was pointed towards the Nokogiri gem recently to find all html elements with a particular class, rather than attempting my own regular expression. (Thanks John-John Tedro and Hassan Schroeder) It works perfectly on my local machine, (Lion OS X and passenger), but when I deployed it to my server (Centos 5.5 and passenger) Nokogiri seems to not grab all the elements of the html file. Here is my method: = def find_editable code = Nokogiri::HTML(open(source_code(FtpAction::DOWNLOAD))) # source_code() method returns a location of a file within the app Rails.logger.info = code Rails.logger.info code.inspect elements = [] num = 0 code.css('.my-class').each do |el| # I tried using xpath, but was not able to get it to grab elements w/ 'class=my-class icon' # only 'class=my-class' attrs = [] el.attributes.each { |attr| attrs {attr[0] = attr[1].value } } elements {:element = el.name, :attributes = attrs, :content = el.content, :count = num+=1 } end Rails.logger.info elements Rails.logger.info elements.inspect elements # array return of hash built above, containing: # name (html tag) # attributes (classes and ids and anything else) # content actual text within element Hello World! end == Below is the output from the log files. You don't really need to go through all of the local output. The whole .html file is being parsed. If anyone has any idea why Nokogiri is not working on my server but would be locally, I would appreciate any help you can provide. Also I did check that the full .html file is there on the server and using File.open do |file| printed out the full file for me. Thank you in advance. Output from Rails.logger.info: -- Server (Centos 5.5) = code #Nokogiri::HTML::Document:0x5d14890 name=document children=[#Nokogiri::XML::DTD:0x5d14624 name=html] elements [] Locally (Lion OS X) = code #Nokogiri::HTML::Document:0x81f508d0 name=document children=[#Nokogiri::XML::DTD:0x81f4fd2c name=html, #Nokogiri::XML::Element:0x81f4fcb4 name=html attributes=[#Nokogiri::XML::Attr:0x81f4b5b0 name=lang value=en] children=[#Nokogiri::XML::Element:0x81f4aa84 name=head children=[#Nokogiri::XML::Element:0x81f4a3b8 name=meta attributes=[#Nokogiri::XML::Attr:0x81f4a0fc name=charset value=utf-8], #Nokogiri::XML::Element:0x81f4a264 name=meta attributes=[#Nokogiri::XML::Attr:0x81f49918 name=http-equiv value=X-UA-Compatible, #Nokogiri::XML::Attr:0x81f49904 name=content value=IE=edge,chrome=1], #Nokogiri::XML::Element:0x81f499a4 name=title children=[#Nokogiri::XML::Text:0x81f47e4c Mut8 Test Site], #Nokogiri::XML::Element:0x81f47cd0 name=meta attributes=[#Nokogiri::XML::Attr:0x81f47bf4 name=name value=description, #Nokogiri::XML::Attr:0x81f47be0 name=content], #Nokogiri::XML::Element:0x81f47c80 name=meta attributes=[#Nokogiri::XML::Attr:0x81f47320 name=name value=author, #Nokogiri::XML::Attr:0x81f4730c name=content]], #Nokogiri::XML::Element:0x81f4677c name=body children=[#Nokogiri::XML::Text:0x81f46470 \n \t, #Nokogiri::XML::Element:0x81f46420 name=header children=[#Nokogiri::XML::Element:0x81f46128 name=hgroup children=[#Nokogiri::XML::Element:0x81f45ea8 name=h1 children=[#Nokogiri::XML::Text:0x81f45c14 Mut8 Testing], #Nokogiri::XML::Text:0x81f45aac \n \t, #Nokogiri::XML::Element:0x81f45a5c name=h2 children=[#Nokogiri::XML::Text:0x81f45764 In Progress...], #Nokogiri::XML::Text:0x81f455fc \n \t ]], #Nokogiri::XML::Element:0x81f453cc name=div attributes=[#Nokogiri::XML::Attr:0x81f4514c name=id value=content] children=[#Nokogiri::XML::Text:0x81f4307c \n \t , #Nokogiri::XML::Element:0x81f4302c name=h3 children=[#Nokogiri::XML::Text:0x81f42d34 My Page Title Here!], #Nokogiri::XML::Text:0x81f42bcc \n \t , #Nokogiri::XML::Element:0x81f42b7c name=p attributes=[#Nokogiri::XML::Attr:0x81f42a28 name=id value=villa, #Nokogiri::XML::Attr:0x81f42a14 name=class value=bob my-class] children=[#Nokogiri::XML::Text:0x81f42410 Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nulla eu ipsum urna, et molestie mi. \n \t \t Aliquam adipiscing, massa et fermentum ullamcorper, neque nunc consectetur enim, imperdiet \n \t \t porta lacus est non turpis. Nam id nisi vitae enim scelerisque ullamcorper vel nec magna. \n \t \t Morbi erat augue, mattis non imperdiet ac, dignissim in velit.], #Nokogiri::XML::Text:0x81f422a8 \n\n\t , #Nokogiri::XML::Element:0x81f42258 name=p attributes=[#Nokogiri::XML::Attr:0x81f42104 name=class value=my-class icon] children=[#Nokogiri::XML::Text:0x81f41cb8 Pellentesque dapibus, nisl non venenatis vehicula, quam tortor placerat lacus, hendrerit \n\t commodo nunc nisl non jusdddto. Donec erat nulla, facilisis fringilla vestibulum et, iaculis \n\t eu metus. Sed aliquet ultrices nunc quis pulvinar. Quisque facilisis dolor sed mauris
[Rails] call a controller action from another controller
Hi people I want to know if it is possible to call an action that belongs to a controller from another action that belongs to a different controller. I have the search action in the controller of Model A , and I need to cal that action from the action register, but action register belongs to the controler of Model B. Also I need to pass some parameters from action register to execute action search Is that possible? -- 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] Nokogiri gem issues
On Fri, Aug 26, 2011 at 9:06 AM, Keith Raymond li...@ruby-forum.com wrote: I recently was pointed towards the Nokogiri gem recently to find all html elements with a particular class, rather than attempting my own regular expression. It works perfectly on my local machine, (Lion OS X and passenger), but when I deployed it to my server (Centos 5.5 and passenger) Nokogiri seems to not grab all the elements of the html file. I'll guess your server has an older (buggier) libxml2 than your Mac -- you can check versions using `xmllint --version`. If it's older, try upgrading and see if that fixes it. -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-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] Observer for checkbox
Hi! I want to put a checkbox on my data list in index view, and change his value on database when I change the value of this chekbox. Someone know how is the good way for do it? Thanks! -- *Fernando Aureliano* -- 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: How to safely embed JSON object in HTML document
Paul, thanks for the suggestion. I was hoping there is something in Rails to do that for me. But I guess there isn't. Other suggestion I got, off this list, is to have JSON embedded in a javascript string, and parsed by jQuery into an object. With proper javascript escaping (by j method), that gets the job done. And I like that approach better then calling h on attributes on server side, as this is more generic IMO, since it will work for any Ruby object. Here is the code that works: % tags = [{name:tag1, color:green}, {name:/scriptbI can \n\ndo something bad here/b, color:red}] % script type=text/javascript charset=utf-8 //![CDATA[ var tags_list = $.parseJSON('%=j tags.to_json.html_safe %'); // ]] /script And that results in: script type=text/javascript charset=utf-8 //![CDATA[ var tags_list = $.parseJSON('[{\name\:\tag1\,\color\:\green\},{\name\:\\/scriptbI can \\n\\ndo something bad here\/b\,\color\:\red\}]'); // ]] /script Thanks all! On Fri, Aug 26, 2011 at 4:43 PM, Peter Hickman peterhickman...@googlemail.com wrote: The purpose of JSON is to be able to interchange the data between various systems. As you are not going to do that then why use JSON at all? Honestly if you are going to process the JSON with Javascript what dont you write your data out as Javascript data structures (which it would be converted from JSON anyway) in the page and process that? What do you gain from embedding the JSON then having to convert it into Javascript data structures over just writing the native Javascript data structures? -- 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] call a controller action from another controller
create a module and move that method here. then just include into your controllers and use tom On Aug 26, 2011, at 18:29 , Angelo Cordova wrote: Hi people I want to know if it is possible to call an action that belongs to a controller from another action that belongs to a different controller. I have the search action in the controller of Model A , and I need to cal that action from the action register, but action register belongs to the controler of Model B. Also I need to pass some parameters from action register to execute action search Is that possible? -- 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. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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: call a controller action from another controller
I've start reading about modules, and it seems to be what I need Thanks for your help On Aug 26, 2:22 pm, Tom Meinlschmidt to...@meinlschmidt.com wrote: create a module and move that method here. then just include into your controllers and use tom On Aug 26, 2011, at 18:29 , Angelo Cordova wrote: Hi people I want to know if it is possible to call an action that belongs to a controller from another action that belongs to a different controller. I have the search action in the controller of Model A , and I need to cal that action from the action register, but action register belongs to the controler of Model B. Also I need to pass some parameters from action register to execute action search Is that possible? -- 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 athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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: Nokogiri gem issues
I did $ yum list updates and the only one that said there was an update that was close to libxml2 was 'libxml2-python'. I updated that and it still does not work. When I checked the version, the output was this: === xmllint --version xmllint: using libxml version 20626 compiled with: Threads Tree Output Push Reader Patterns Writer SAXv1 FTP HTTP DTDValid HTML Legacy C14N Catalog XPath XPointer XInclude Iconv ISO8859X Unicode Regexps Automata Expr Schemas Schematron Modules Debug === Is there any other dependancies that I may need to update as well? Thank you for the reply and your help -- 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] call a controller action from another controller
just create my_module.rb in lib/ module MyModule def my_method … end end and in your controller just class MyController ApplicationController include MyModule def search my_method(params) end end just check whether your module is loaded or add require to your config/environment.rb file tom On Aug 26, 2011, at 20:49 , Angelo Cordova wrote: I've start reading about modules, and it seems to be what I need Thanks for your help On Aug 26, 2:22 pm, Tom Meinlschmidt to...@meinlschmidt.com wrote: create a module and move that method here. then just include into your controllers and use tom On Aug 26, 2011, at 18:29 , Angelo Cordova wrote: Hi people I want to know if it is possible to call an action that belongs to a controller from another action that belongs to a different controller. I have the search action in the controller of Model A , and I need to cal that action from the action register, but action register belongs to the controler of Model B. Also I need to pass some parameters from action register to execute action search Is that possible? -- 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 athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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] Issue with scruffy
Hi im trying to render a simple graph for the moment just to test the library but i'm having a problem... i try to run this example from other page. graph = Scruffy::Graph.new graph.title = Favourite Snacks graph.renderer = Scruffy::Renderers::Pie.new graph.add :pie, '', { 'Apple' = 20, 'Banana' = 100, 'Orange' = 70, 'Taco' = 30 } graph.render :to = pie_test.svg graph.render :width = 300, :height = 200, :to = pie_test.png, :as = 'png' and i get an error in graph.render :width = 300, :height = 200, :to = pie_test.png, :as = 'png' no such file to load -- RMagick i haven't found in any place something that says that scruffy needs rmagick to work... it's really necesary to install it for render the graph in a view? I only ask because i'm having problems to install rmagick, it says that it failed building the native extencion even if i have installed the devkit -- 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: Nokogiri gem issues
On Fri, Aug 26, 2011 at 12:04 PM, Keith Raymond li...@ruby-forum.com wrote: I did $ yum list updates and the only one that said there was an update that was close to libxml2 was 'libxml2-python'. I don't think that's relevant :-) I updated that and it still does not work. When I checked the version, the output was this: === xmllint --version xmllint: using libxml version 20626 On my Mac (Snow Leopard) version 20708 On a very old SuSE box (home office spare) version 20620 On an Ubuntu server provisioned in the last year version 20626 So I would bet that difference could still account for your problem. I rarely use package managers like yum; usually it seems faster and easier to just install/update from source :-) You might want to research the change history but I would probably just update and see what happens... FWIW, -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-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] strings issue
Hi everybody, I ve got a problem with strings and the class File in rails Indeed, when i try to do this: File.new(archives/sequences/archives-2011.xml) it works perfectly, however when i do string = archives/sequences/ + @filename = filename being archives-2011.xml File.new(string) it doesn't work! ruby tells me it cannot find the file does anyone could tell me why? 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] Unsubscribe
Unsubscribe Sent from my iPad On Aug 26, 2011, at 12:35 PM, Hassan Schroeder hassan.schroe...@gmail.com wrote: On Fri, Aug 26, 2011 at 12:04 PM, Keith Raymond li...@ruby-forum.com wrote: I did $ yum list updates and the only one that said there was an update that was close to libxml2 was 'libxml2-python'. I don't think that's relevant :-) I updated that and it still does not work. When I checked the version, the output was this: === xmllint --version xmllint: using libxml version 20626 On my Mac (Snow Leopard) version 20708 On a very old SuSE box (home office spare) version 20620 On an Ubuntu server provisioned in the last year version 20626 So I would bet that difference could still account for your problem. I rarely use package managers like yum; usually it seems faster and easier to just install/update from source :-) You might want to research the change history but I would probably just update and see what happens... FWIW, -- Hassan Schroeder hassan.schroe...@gmail.com http://about.me/hassanschroeder twitter: @hassan -- You received this message because you are subscribed to the Google Groups Ruby on Rails: Talk group. To post to this group, send email to rubyonrails-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] Unsubscribe
On 26 August 2011 21:38, Stephen Dame sdame...@gmail.com wrote: Unsubscribe It says this at the bottom of each message... To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.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] strings issue
On 26 August 2011 21:22, thelo.g thelo li...@ruby-forum.com wrote: string = archives/sequences/ + @filename = filename being archives-2011.xml File.new(string) it doesn't work! ruby tells me it cannot find the file Output the value of string and see what it 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.
Re: [Rails] strings issue
On 26 August 2011 21:22, thelo.g thelo li...@ruby-forum.com wrote: Hi everybody, I ve got a problem with strings and the class File in rails Indeed, when i try to do this: File.new(archives/sequences/archives-2011.xml) it works perfectly, however when i do string = archives/sequences/ + @filename = filename being archives-2011.xml File.new(string) it doesn't work! ruby tells me it cannot find the file Show us the exact error message. Copy and paste it into the post, don't retype it. Colin does anyone could tell me why? 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. -- Colin https://plus.google.com/111605230843729345543/ -- 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: strings issue
No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): 1: h1Résultat/h1 pid :%= @result % % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % Rails.root: /home/thelo/RoR/ihm_test Application Trace | Framework Trace | Full Trace app/views/pages/print_result.html.erb:1:in `initialize' app/views/pages/print_result.html.erb:1:in `open' app/views/pages/print_result.html.erb:1:in `_app_views_pages_print_result_html_erb__106515637_82305240_211210089' -- 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: strings issue
thelo.g thelo wrote in post #1018716: Hi everybody, I ve got a problem with strings and the class File in rails Indeed, when i try to do this: File.new(archives/sequences/archives-2011.xml) it works perfectly, however when i do string = archives/sequences/ + @filename = filename being archives-2011.xml File.new(string) it doesn't work! ruby tells me it cannot find the file You lie: str1 = 'archives/sequences/archives-2011.xml' @filename = 'archives-2011.xml' str2 = archives/sequences/ + @filename puts str1 == str1 --output:-- true -- 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: strings issue
And the output of the string is: ActionView::Template::Error (No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml -- 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: strings issue
@7stud no I do not, I might have bad explained the problem. the thing is when i perform the following code: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % I got this error: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): 1: h1Résultat/h1 pid :%= @result % % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % Rails.root: /home/thelo/RoR/ihm_test Application Trace | Framework Trace | Full Trace app/views/pages/print_result.html.erb:1:in `initialize' app/views/pages/print_result.html.erb:1:in `open' app/views/pages/print_result.html.erb:1:in `_app_views_pages_print_result_html_erb__106515637_82305240_211210089' and in the console ActionView::Template::Error (No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml So when i replace string by Archives-2011-08-26-09-56-00-UTC.xml everything is ok, no problem. I just want to understand why and fix this problem 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] Re: Nokogiri gem issues
Keith Raymond wrote in post #1018677: # I tried using xpath, but was not able to get it to grab elements w/ 'class=my-class icon' # only 'class=my-class' If you give up on installing a newer version of libxml (I've tried it in the past and found it impossible), you can use xpath() to do what you want: !DOCTYPE html html head titleTest/title /head body h1 class='editor highlight'Hello world/h1 div class=editor_fruit redApple/div div class=article_editor divNot this node/div div class=hide editorPapillon/div /div /body /html require 'nokogiri' f = File.open('2html.htm') doc = Nokogiri::HTML(f) results = doc.xpath(//*[contains(concat(' ', @class, ' '), ' editor ')]).each do |el| p [ el.attributes['class'].value, el.children[0].text ] end --output:-- [editor highlight, Hello world] [hide editor, Papillon] -- 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] Double Render Error
Hi, I keep double render error after updating rails. Heres my code, any suggestions? def show if_user_formulated_request_properly do @input_messages = InputMessage.search_by(params[:query].strip) unless params[:query].blank? end respond_to do |format| format.html #default rendering end end end def if_user_formulated_request_properly unless request.post? flash[:error] = This page can only be accessed through the search page. (POST request only) redirect_to(:action = index) and return end if params[:query].blank? flash[:error] = Search criteria can not be blank redirect_to(:action = index) and return end if !(params[:query] =~ /-/) flash[:error] = ( Format of search criteria is wrong.br / Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8) redirect_to(:action = index) and return end if !(QueryParser.expression.match(params[:query])) flash[:error] = %( Format of search criteria is wrong.br / Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8) redirect_to(:action = index) and return end yield -- 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] strings issue
full patch of archives is? if under rails root, then change code to string = Rails.root.to_s+'/archives/results/'+r or write down full path to archives directory tom On Aug 26, 2011, at 23:23 , thelo.g thelo wrote: @7stud no I do not, I might have bad explained the problem. the thing is when i perform the following code: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % I got this error: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): 1: h1Résultat/h1 pid :%= @result % % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % Rails.root: /home/thelo/RoR/ihm_test Application Trace | Framework Trace | Full Trace app/views/pages/print_result.html.erb:1:in `initialize' app/views/pages/print_result.html.erb:1:in `open' app/views/pages/print_result.html.erb:1:in `_app_views_pages_print_result_html_erb__106515637_82305240_211210089' and in the console ActionView::Template::Error (No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml So when i replace string by Archives-2011-08-26-09-56-00-UTC.xml everything is ok, no problem. I just want to understand why and fix this problem 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. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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: strings issue
I tried but it doesn't work, is it possible that the mistake has a ling with \n at the end of r? because when I do: puts '' + r + '' I get Archives-2011-08-26-09-56-00-UTC.xml -- 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: strings issue
thelo.g thelo wrote in post #1018731: @7stud no I do not, I might have bad explained the problem. the thing is when i perform the following code: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % % f = File.open(string) % I got this error: No such file or directory - ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml Extracted source (around line #1): 1: h1Résultat/h1 pid :%= @result % % r = Result.find(@result).nameFile % % string = ./archives/results/ + r % So when i replace string by Archives-2011-08-26-09-56-00-UTC.xml ('./archives/results' + r) is not the same thing as Archives-2011-08-26-09-56-00-UTC.xml You have proved nothing. -- 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] Double Render Error
add respond_to :html to your controller and change respond_to do |format| format.htm ... end to respond_with(@input_messages) .. tom ps: or add 'return' to your condition if condition has been met (eg in show method) On Aug 26, 2011, at 17:59 , jak1192 wrote: Hi, I keep double render error after updating rails. Heres my code, any suggestions? def show if_user_formulated_request_properly do @input_messages = InputMessage.search_by(params[:query].strip) unless params[:query].blank? end respond_to do |format| format.html #default rendering end end end def if_user_formulated_request_properly unless request.post? flash[:error] = This page can only be accessed through the search page. (POST request only) redirect_to(:action = index) and return end if params[:query].blank? flash[:error] = Search criteria can not be blank redirect_to(:action = index) and return end if !(params[:query] =~ /-/) flash[:error] = ( Format of search criteria is wrong.br / Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8) redirect_to(:action = index) and return end if !(QueryParser.expression.match(params[:query])) flash[:error] = %( Format of search criteria is wrong.br / Should be [IXLSpecClass value][year]-[Message ID] for example GP07-8) redirect_to(:action = index) and return end yield -- 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. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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: strings issue
I meant when i replace string by ./archives/results/Archives-2011-08-26-09-56-00-UTC.xml, which is normally similar to './archives/results' + r -- 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: Double Render Error
Who wrote that code? -- 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: strings issue
On Aug 26, 2011, at 23:51 , thelo.g thelo wrote: I tried but it doesn't work, is it possible that the mistake has a ling with \n at the end of r? because when I do: puts '' + r + '' I get Archives-2011-08-26-09-56-00-UTC.xml \n doesn't matter ruby-1.8.7-p174 :006 File.new(./testfile,'w') = #File:./testfile ruby-1.8.7-p174 :007 File.new(./testfile\n,'w') = #File:./testfile you just cripple the filename .. -- 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. -- === Tomas Meinlschmidt, MS {MCT, MCP+I, MCSE, AER}, NetApp Filer/NetCache www.meinlschmidt.com www.maxwellrender.cz www.lightgems.cz === -- 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: strings issue
What do you mean? and if this is the case, how can I fix it? -- 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: PGError: server closed the connection unexpectedly
Well my setup is different, I use rails 3+, I've used pg 0.10 and now pg 0.11, posgresql 8.4, ruby 1.8.7 and the current passenger. -- 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/-/REy3nxE8I-EJ. 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: strings issue
thelo.g thelo wrote in post #1018739: I tried but it doesn't work, is it possible that the mistake has a ling with \n at the end of r? because when I do: puts '' + r + '' I get Archives-2011-08-26-09-56-00-UTC.xml It's not only possible, that is exactly what is at the end of r. When you are having such a problem, it is easier to see what the string actually contains by doing one of the following: 1) puts --#{some_var}--- 2) p r which is the same as: puts r.inspect Here is an example: str = hello world p str --output:-- hello\nworld And of course the newline makes a difference in the file name. You can test that yourself: some_file = html.htm File.open(some_file) do |f| puts f.read end Once you get that to work with a file on your file system, try adding a \n to the 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-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: strings issue
Tom Meinlschmidt wrote in post #1018745: \n doesn't matter ruby-1.8.7-p174 :006 File.new(./testfile,'w') = #File:./testfile ruby-1.8.7-p174 :007 File.new(./testfile\n,'w') = #File:./testfile you just cripple the filename .. Really?? I don't see a crippled filename. .. . . . . . . -- 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 override*
Hi Team, I have create one ruby on rails application ,i have one issue for that image upload ,the image will override the some user , so any can solve the issues contoller class PhotosController ApplicationController # GET /photos # GET /photos.xml def index @photos = Photo.all respond_to do |format| format.html # index.html.erb format.xml { render :xml = @photos } end end # GET /photos/1 # GET /photos/1.xml def show @photo = Photo.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml = @photo } end end # GET /photos/new # GET /photos/new.xml def new @photo = Photo.new respond_to do |format| format.html # new.html.erb format.xml { render :xml = @photo } end end # GET /photos/1/edit def edit @photo = Photo.find(params[:id]) end # POST /photos # POST /photos.xml def create @photo = Photo.new(params[:photo]) respond_to do |format| if @photo.save format.html { redirect_to(@photo, :notice = 'Photo was successfully created.') } format.xml { render :xml = @photo, :status = :created, :location = @photo } else format.html { render :action = new } format.xml { render :xml = @photo.errors, :status = :unprocessable_entity } end end end # PUT /photos/1 # PUT /photos/1.xml def update @photo = Photo.find(params[:id]) respond_to do |format| if @photo.update_attributes(params[:photo]) format.html { redirect_to(@photo, :notice = 'Photo was successfully updated.') } format.xml { head :ok } else format.html { render :action = edit } format.xml { render :xml = @photo.errors, :status = :unprocessable_entity } end end end # DELETE /photos/1 # DELETE /photos/1.xml def destroy @photo = Photo.find(params[:id]) @photo.destroy respond_to do |format| format.html { redirect_to(photos_url) } format.xml { head :ok } end end end class Photo ActiveRecord::Base # Root directory of the photo public/photos PHOTO_STORE = File.join RAILS_ROOT, 'public', 'images' # Invoke save_photo method when save is completed after_save :save_photo def load_photo_file=(data) # Record the filename self.filename = data.original_filename # Store the data for later use @photo_data = data end name = File.join PHOTO_STORE, self.filename File.open(name, 'wb') do |f| f.write(@photo_data.read) end @photo_data = nil end end end def fileexist if FileTest.exists?(RAILS_ROOT + public/images/#{@photo_data}) render :text = yes else render :text = no end end table tr thFilename/th /tr % @photos.each do |photo| % tr td%=h photo.filename %/td td%= image_tag photo.filename%/td td%= link_to 'Show', photo %/td td%= link_to 'Edit', edit_photo_path(photo) %/td td%= link_to 'Destroy', photo, :confirm = 'Are you sure?', :method = :delete %/td /tr % end % /table br / %= link_to 'New ', new_photo_path % -- 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.