[Rails] Phone format in Rails
Guys, I have a text field and the name is phone I used to enter contact number. In the new form when i enter 10 digit number like "1234567890" it is displaying 1234567890 I want to display like in US format automatically like "(123) 456-7890". I need to provide validation for that field also. Can u help me how can i do that. Very badly i need a help. i am struck with this issue.. --~--~-~--~~~---~--~~ 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] Simple Captcha setup problem
$ rake simple_captcha:setup rake aborted! libMagickCore.so.1: cannot open shared object file: No such file or directory - /usr/lib/ruby/site_ruby/1.8/x86_64-linux/RMagick.so (See full trace by running task with --trace) 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] Error during rake db:migrate
Hi, I am using rails 2.2. I am getting an error during migration. Whenever I am running "rake db:migrate", I am getting an error "(in E:/Rails2.2/rails_demo) !!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql. rake aborted! 126: The specified module could not be found. - E:/ruby/lib/ruby/gems/1.8/gems /mysql-2.7.3-x86-mswin32/ext/mysql.so " I installed mysql gem by using "gem install mysql". My gem list is :: *** LOCAL GEMS *** actionmailer (2.2.2) actionpack (2.2.2) activerecord (2.2.2) activeresource (2.2.2) activesupport (2.2.2) cgi_multipart_eof_fix (2.5.0) fxri (0.3.6) fxruby (1.6.12) gem_plugin (0.2.3) hpricot (0.6) log4r (1.0.5) mongrel (1.1.2) mysql (2.7.3) rails (2.2.2) rake (0.8.3, 0.7.3) ruby-debug-base (0.10.0) ruby-debug-ide (0.1.10) rubygems-update (1.3.1) Can any help me out to solve this error? Thanks, Tushar -- 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] managing multiple rails applications with apache
how can manage multiple rails applications with apache i have followed the following tutorial and successfullt set up my rails site using apache http://www.howtoforge.com/ruby_on_rails_debian_etch http://www.howtoforge.com/ruby_on_rails_debian_etch_p2 but how can i configure apache to host more than one rails site ? --~--~-~--~~~---~--~~ 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: ActiveWebService returning custom types
disregard this section #[get_indices(),get_stocks(),get_summary(),DateTime.now.to_s] indices = get_indices() stocks = get_stocks() summary = get_summary() current_time = DateTime.now tempsnapshot = Snapshot.new(indices,stocks,summary,current_time) tempsnapshot -- 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] ActiveWebService returning custom types
class Sampleclass attr_reader :temp_arr,:temp_hash,:temp_str def initialize(temp_arr,temp_hash,temp_str) @temp_arr=temp_arr @temp_hash=temp_hash @temp_str=temp_str end class TestApi < ActionWebService::API::Base api_method :get_me, :returns => [Sampleclass] end class TestController < ApplicationController wsdl_service_name 'Test' web_service_api TestApi web_service_scaffold :invocation if Rails.env == 'development' def get_me #[get_indices(),get_stocks(),get_summary(),DateTime.now.to_s] indices = get_indices() stocks = get_stocks() summary = get_summary() current_time = DateTime.now tempsnapshot = Snapshot.new(indices,stocks,summary,current_time) tempsnapshot [Sampleclass.new(['1','2',3'], {'a' => '1', 'b' => '2' }, 'something' ) ] end end i got this error Don't know how to cast Sampleclass to Sampleclass how do i define custom classes as return paramters -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] How to access the binding of the caller within a method
Probably this is a ruby trick instead of Rails'. But the context of my question is in Rails. There are a lot of prompt to user in our Rails app. I don't want to hard-code those prompt every where, since they will be change by the product team. Then I put all of them in a yml file and load the yml file as a hash to read the prompts in controllers. All works fine except that sometimes there needs to be some dynamic content in the prompts. Like <%=boy%> kissed <%=girl%> Then I used ERB to substitute the dynamic content: boy = "Tom" girl = "Jenny" raw_string = load_yml['test_prompt'] flash[:notice]=ERB.new(raw_string).result(binding) That works, but it make each call a bit hurt. I want to be able to just: flash[:notice] = properties['test_prompt'], or flash[:notice] = properties 'test_prompt' And it is able to substitute those local variables. So I def a method called properties to load yml and use ERB to analyze the dynamic content. But the problem is how to get the binding of the caller? Or is there any other "beautiful" way to make property files dynamic? --~--~-~--~~~---~--~~ 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] table lock
How to lock a table in rails not row level lock . -- Posted via http://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] How to Change Up Methods According to Parameter
Hi.. I have two methods.but the parameter will be changing. For the first method i send only one parameter(f). But for the second method i'll send 3 parameters(f,search_string_1,search_string_2). And also for 3rd Method i send Two Parameter(f,search_string). Is it possible to optimise below methods into Single Methods . How can i combine the below Three Methods into one method pls help me. #method 1 def check_chat_type(f) Dir.foreach(File.join(RAILS_ROOT + "/public/ACMServer_exe/ChatHistory",f)) do sub_folder_name| if sub_folder_name.include? "Vs" get_path(f,sub_folder_name) end end end #method 2 def check_chat_type(f,search_string_1,search_string_2) Dir.foreach(File.join(RAILS_ROOT + "/public/ACMServer_exe/ChatHistory",f)) do |sub_folder_name| if sub_folder_name.include? "Vs" if sub_folder_name.include?(search_string_1) if sub_folder_name.include?(search_string_2) get_path(f,sub_folder_name) end end end end end #Method 3 def check_chat_type(f,search_string) Dir.foreach(File.join(RAILS_ROOT + "/public/ACMServer_exe/ChatHistory",f)) do |sub_folder_name| if sub_folder_name.include? "Vs" if sub_folder_name.include?(search_string) get_path(f,sub_folder_name) end end 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-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: Preventing read access to a model
Go to http://api.rubyonrails.org/ read about ActiveRecord::Callbacks See also restful_authentication gem and simple_access_control plugin - use them both. On Mar 1, 12:34 pm, Evan wrote: > In a model are there any methods that are called before providing > access to the model? > > I'm exploring ways to enforce privileges in my app. Wondering if I can > define some sort of "before" method in the model to prevent read > access to the model unless certain conditions are true. > > Thanks. > > Evan --~--~-~--~~~---~--~~ 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] Accessing helpers within partials within helpers
Hi everyone, not sure if this is a bug or just normal behaviour: >From a layout file call a helper, inside that helper render a partial, inside that partial call a different helper. I find that the last helper doesn't actually get called, and when I try to inspect its class it's NilClass. Is this a scoping problem? Cheers, Brendon --~--~-~--~~~---~--~~ 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: validates_uniqueness_of - how did I get two users?
In ActiveRecord::Base, the save method takes a flag called perform_validation, which you can set to false. Check your controller code to make sure someone didn't decide to skip the validations somewhere. On Sat, Feb 28, 2009 at 4:39 PM, phil wrote: > > The odd thing is that the users were created through the website two > months apart! --~--~-~--~~~---~--~~ 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: Rails Magazine - Issue #1 is now available
Wow, I have to admit it looks like a magazine, laying out there in the open with pictures and all. I'll check back when the pdf is available to see if it look like a USEFUL magazine. :) --Michael On Sun, Mar 1, 2009 at 10:13 AM, Olimpiu Metiu wrote: > > I am happy to announce the very first issue of Rails Magazine! > > This edition has 36 pages full of quality content, is printed in > glossy full-color and can be ordered in US, UK and Canada. The paper > is FSC certified for minimal environment impact. > > The free digital edition (PDF) is well underway and will be available > globally in about 2 weeks. > > I would like to thank everyone who contributed to the magazine, and > invite others to do the same. > > Please visit our web site for previews and additional details: > http://railsmagazine.com > > If you like the idea of a high-quality, free Ruby and Rails > publication, please help us promote Rails Magazine. Tweet, blog, link > to us, join us on Facebook and otherwise spread the word: > http://railsmagazine.com/share! > > Thank you, > Olimpiu Metiu > Editor | Rails Magazine > > > > -- (Ruby, Rails, Random) blog: http://skandragon.blogspot.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: creating a rails plugin
I hope this book will help you create a plugin. http://rapidshare.com/files/204193424/Addison-Wesley-Extending_Rails_Beyond_the_Core.chm.html Best regards Rob. Maurício Linhares wrote: > Usually, plugins do it by using polymorphic associations, so they > don't need to know in advance the real class that's going to be > referenced. > > - > Maurício Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) > > > > On Wed, Feb 25, 2009 at 1:21 AM, Amita Bhatkhande > wrote: > >> Thanks for the link.. I am going through the guide. >> However, I am still wondering how can I include associations (has_many >> and belongs_to methods) in my plugin. Because I do not know what will be >> the model/table name used by user to associate my plugin's model to.. >> >> e.g.: for one application it could be user- :has_many photos or for >> another application- user :has_many songs . >> >> Thanks, >> Amita. >> >> >> Maurício Linhares wrote: >> >>> What you`re looking for is a way to configure your plugin, the >>> simplest way to do it is just let the user reopen your classes and >>> change what is need in a initialization file. You could also create a >>> configuration file and have your plugin to load it and configure the >>> pieces that are "configurable", like the model that`s going to be used >>> (in your case, the photos our albuns). >>> >>> Also, model plugins are usually small and very specific in what they >>> do, your plugin seems to do a lot and this isn't really common when >>> dealing with plugins. Some plugins, like restful_auth, don't even use >>> models, but contain modules that are included in your models, this is >>> better `cos it's easier for someone using your plugin to override your >>> behaviour. >>> >>> You should definitely take a look at the Rails Plugins patterns PDF -> >>> http://peepcode.com/products/rails-2-plugin-patterns >>> >>> - >>> Maurício Linhares >>> http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ >>> (en) >>> >>> >>> >>> On Sun, Feb 22, 2009 at 8:00 PM, Amita Bhatkhande >>> >> -- >> 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: before_save :strip_whitespace => saves with spaces
Newb Newb wrote: > Thanks for the reply. > Could you tell me the way of implementation pls. > How can i resolve it. > > > Thanks in advance > change line value = value.strip to: self[attr] = value.strip --~--~-~--~~~---~--~~ 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: background process
I think you can use ActiveMQ and Activemessaging plugin http://code.google.com/p/activemessaging/wiki/ActiveMessaging http://activemq.apache.org/ Frederick Cheung wrote: > On 23 Feb 2009, at 10:38, Ankit Parekh wrote: > > >> Hi all >> >> I am working on a heavy engineering project. And the requirement is >> that >> I needto do a lot of process before I store the data to the db. >> >> Now the question is that I want to do the process that I am doing >> but I >> want to do it in the background. What I actually mean to say is >> that..I >> just want the user to get a msg that Records Saved. But in real I want >> the process to go on in background. >> >> There r multiple callbacks used in my system. Also I dont want to use >> Starling or workling. pls suggest something where in my requirement is >> satisfied. Since i dont want the user to wait until my process is >> going >> on. >> >> > Well one of the other background processors (bj, backgroundrb etc. ) > might do the job > > Fred > >> 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] Preventing read access to a model
In a model are there any methods that are called before providing access to the model? I'm exploring ways to enforce privileges in my app. Wondering if I can define some sort of "before" method in the model to prevent read access to the model unless certain conditions are true. Thanks. Evan --~--~-~--~~~---~--~~ 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: Find or select across a many to many relationship
Oh yes. Very nice. Thanks. AR is very aware! Clever AR! -- Matt On Mar 1, 7:37 pm, Frederick Cheung wrote: > On Mar 1, 5:52 pm, johnsonmlw wrote: > > > I have an incident model and a pupil model, and they have a many to > > many relationship through an involvement model. Also, a pupil belongs > > to a cohort. > > > How can I show incidents (ideally just once), in date order, where > > there is an involvement present from a pupil where their > > pupil.cohort_id == 1 ? > > One way would be something like Incident.find :all, :joins > => :pupil, :conditions => ["pupils.cohort_id = ?", 1] > This joins the pupils table (AR is smart enough to know that in needs > to join the involvements tables as well) and then you can easily apply > conditions on pupils order stuff etc... > > You'll need to put a distinct in there not to get duplicate rows. > > > > > At the moment, I'm finding all pupils where pupil.cohort_id ==1, then > > iterating through the @pupils, listing the involvements/incident > > details for those pupils. But this isn't great, as (i) incidents show > > up more than once where two pupils are involved in the incident, and > > (ii) I can't order by incident date. It feels backwards. > > > I suspect maybe I can use > > > @incidents = Incident.find(:all) > > @incidents = @incidents.select {|i| ... something something to do with > > involvements then pupil.cohort_id == 1? > > Anything that starts with Foo.find(:all) will run out of steam when > there starts to be a large number of foos. > > Fred > > > > > Maybe I'm miles off? > > > Help or clues appreciated. --~--~-~--~~~---~--~~ 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: Scope of Instance Variables with Partial Views
On Mar 1, 9:12 pm, Rube Noob wrote: > Hi Fred, > > Thanks for your response, > > Basically what I am trying to accomplish is have to partial views in the > index page. One for the list of items and one for the details of the > selected item. In the future I hope to add new functionality to the > index page and I hope that the index method will not have to deal with > all the different actions that I add. > > I understand how this is a new HTTP request and that the > @current_selected variable is lost. Is there any way I can allow the > view to see this variable without involving the index method? > Nope, you'd have to pass a parameter to the index action (although whether manipulation of that parameter happens in the index action itself or in a before_filter is up to you) Fred > rube_noob > > > > Frederick Cheung wrote: > > On Mar 1, 8:48 pm, Rube Noob wrote: > >> def detail_display > >> @current_selected = @item= Item.find(params[:id]) > >> redirect_to :action => :index > >> end > >> end > > >> detail_display is invoked when the user clicks on an item in the list. > >> The variable @current_selected is not available to the partial view > >> invoked when the index is redirected to. How can I remedy this? > > > The key thing you need to understand here is that this is an http > > redirect, ie a separate request: by the time the index action is > > rendered the controller object that had the @current_selected instance > > variable has been destroyed and your request is being handled by a > > completely fresh controller object. If the index action needs to know > > what the currently selected object is then you need to pass a > > parameter to it telling it this. In this light, I'm not sure what the > > point of the detail_display action is as it seems to be a complete no- > > op. > > > Fred > > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: restful_authentication issues in production
I just manually set the password reset code in the DB. I then tried to reset the password and it didn't work. What's going on? On Mar 1, 1:01 pm, gaveeno wrote: > I'm not sure what's going on here, but password resets with > restful_authentication aren't working in production. However, they > are working in development and staging. > > The request to the passwords controller's create action is completing > successfully according to the server log: > > Processing PasswordsController#create (for 68.107.52.195 at 2009-03-01 > 14:36:29) [POST] > Parameters: {"commit"=>"Reset Password", > "authenticity_token"=>"a31cf1ba526601835092b65a6b471e9f134cee59", > "email"=>"gavin.to...@gmail.com"} > Redirected to /login > Completed in 592ms (DB: 149) | 302 Found [http://www.mysite.com/ > password] > > However, no password reset code is set in the DB and no email is > delivered. > > The only account on the production app is the administrator account > because I haven't yet opened it up for signups, and like an idiot I > forgot my password so I'm not even sure if logging in works in > production. > > What gives? --~--~-~--~~~---~--~~ 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: Scope of Instance Variables with Partial Views
Hi Fred, Thanks for your response, Basically what I am trying to accomplish is have to partial views in the index page. One for the list of items and one for the details of the selected item. In the future I hope to add new functionality to the index page and I hope that the index method will not have to deal with all the different actions that I add. I understand how this is a new HTTP request and that the @current_selected variable is lost. Is there any way I can allow the view to see this variable without involving the index method? rube_noob Frederick Cheung wrote: > On Mar 1, 8:48�pm, Rube Noob wrote: >> � � def detail_display >> � � � � @current_selected = @item= Item.find(params[:id]) >> � � � � redirect_to :action => :index >> � � end >> end >> >> detail_display is invoked when the user clicks on an item in the list. >> The variable @current_selected is not available to the partial view >> invoked when the index is redirected to. How can I remedy this? >> > The key thing you need to understand here is that this is an http > redirect, ie a separate request: by the time the index action is > rendered the controller object that had the @current_selected instance > variable has been destroyed and your request is being handled by a > completely fresh controller object. If the index action needs to know > what the currently selected object is then you need to pass a > parameter to it telling it this. In this light, I'm not sure what the > point of the detail_display action is as it seems to be a complete no- > op. > > Fred -- 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] restful_authentication issues in production
I'm not sure what's going on here, but password resets with restful_authentication aren't working in production. However, they are working in development and staging. The request to the passwords controller's create action is completing successfully according to the server log: Processing PasswordsController#create (for 68.107.52.195 at 2009-03-01 14:36:29) [POST] Parameters: {"commit"=>"Reset Password", "authenticity_token"=>"a31cf1ba526601835092b65a6b471e9f134cee59", "email"=>"gavin.to...@gmail.com"} Redirected to /login Completed in 592ms (DB: 149) | 302 Found [http://www.mysite.com/ password] However, no password reset code is set in the DB and no email is delivered. The only account on the production app is the administrator account because I haven't yet opened it up for signups, and like an idiot I forgot my password so I'm not even sure if logging in works in production. What gives? --~--~-~--~~~---~--~~ 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: Scope of Instance Variables with Partial Views
On Mar 1, 8:48 pm, Rube Noob wrote: > Hello > > I do not understand how to use instance variable properly with partial > views, I am hoping someone here can enlighten me. For example > > class MainController < ApplicationController > def index > @item_list = Item.find_all_item > end > > def detail_display > @current_selected = @item= Item.find(params[:id]) > redirect_to :action => :index > end > end > > detail_display is invoked when the user clicks on an item in the list. > The variable @current_selected is not available to the partial view > invoked when the index is redirected to. How can I remedy this? > The key thing you need to understand here is that this is an http redirect, ie a separate request: by the time the index action is rendered the controller object that had the @current_selected instance variable has been destroyed and your request is being handled by a completely fresh controller object. If the index action needs to know what the currently selected object is then you need to pass a parameter to it telling it this. In this light, I'm not sure what the point of the detail_display action is as it seems to be a complete no- op. Fred > Thank you > > rube_noob > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Ajax in Rails
Thanks, I will give this a try, although as a newbie this talk of :locals, :object, etc has slightly gone over my head. I'm sure i'll get it. Phil On Mar 1, 8:37 pm, Phlip wrote: > phil7085 wrote: > > How would I then need to tell rails to use the @advert object because > > that's the part that I have been having trouble with? > > Formerly, it was this: > > def preview > @advert = Advert.new(params[:advert]) > render :partial => 'advert', :locals =>{ :@advert => @advert } > end > > I prefer that style because it makes @advert, inside the partial, safe to test > for nil. However, on our latest new project (Rails 2.2.2) either we did > something else wrong, or the :@ stopped working, and we had to use this: > > render :partial => 'advert', :locals =>{ :advert => @advert } > > Does anyone know if the :@ trick should still work? > > -- > Phlip --~--~-~--~~~---~--~~ 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] Scope of Instance Variables with Partial Views
Hello I do not understand how to use instance variable properly with partial views, I am hoping someone here can enlighten me. For example class MainController < ApplicationController def index @item_list = Item.find_all_item end def detail_display @current_selected = @item= Item.find(params[:id]) redirect_to :action => :index end end detail_display is invoked when the user clicks on an item in the list. The variable @current_selected is not available to the partial view invoked when the index is redirected to. How can I remedy this? Thank you rube_noob -- 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: Ajax in Rails
On Mar 1, 8:42 pm, Phlip wrote: > Frederick Cheung wrote: > > render :partial => 'blah', :object => foo > > To save me from Googling for "object", what does that look like inside the > partial? the object specified in that way is assigned to a local variable called object and to a local variable called after the partial (ie the same thing that happens when you do :collection => foos) (or using the name specified in the :as option) 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: Ajax in Rails
Frederick Cheung wrote: > render :partial => 'blah', :object => foo To save me from Googling for "object", what does that look like inside the partial? --~--~-~--~~~---~--~~ 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: Using belongs_to within instance method
On Mar 1, 8:06 pm, David wrote: > Is it possible to use model associations with an instance method? For > example, I have: > > Class Reminder > belongs_to :event > > #and i want to access the event id within a Reminder instance method: > def find_event_id > > id = Event.find(event_id).user.id > #this works but im wondering if its possible to do something like: > > id = this_reminder.event.user.id? > Unless I'm horribly misunderstanding, why not do event.user.id ? When you do belongs_to :event that creates an instance method called event on the Reminder class, so you can just go ahead and call this. The 'this_reminder' you wrote is basically self but if you don't specify a target for your method calls the ruby assumes self ie self.event.user.id is the same as event.user.id [1] Fred [1] Not quite the same. If you had a local variable called event then when you wrote event.user.id ruby would assume that you were talking about the local variable not the method whereas with self there is no ambiguity Fred > end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Ajax in Rails
phil7085 wrote: > How would I then need to tell rails to use the @advert object because > that's the part that I have been having trouble with? Formerly, it was this: def preview @advert = Advert.new(params[:advert]) render :partial => 'advert', :locals =>{ :@advert => @advert } end I prefer that style because it makes @advert, inside the partial, safe to test for nil. However, on our latest new project (Rails 2.2.2) either we did something else wrong, or the :@ stopped working, and we had to use this: render :partial => 'advert', :locals =>{ :advert => @advert } Does anyone know if the :@ trick should still work? -- Phlip --~--~-~--~~~---~--~~ 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: Ajax in Rails
On Mar 1, 8:12 pm, phil7085 wrote: > Thanks Fred, > > How would I then need to tell rails to use the @advert object because > that's the part that I have been having trouble with? > render :partial => 'blah', :object => foo Fred > Phil > > On Mar 1, 7:41 pm, Frederick Cheung > wrote: > > > On Mar 1, 7:38 pm, phil7085 wrote:> I am simply > > trying to show what the user enters somewhere else on the > > > page as they type it. > > > > I did get it to work using render :text => param[:advert][:title] + > > > '' + param[:advert][:first_line] .. > > > > But I think there should be a more efficient way to do it? > > > > Could I do something like this: > > > > def preview > > > @advert = Advert.new(params[:advert]) > > > render :partial => 'advert' > > > end > > > Something like that is fine (although you'll need to tell rails to use > > the @advert object). It's not more efficient in terms of raw cpu > > cycles but I'm assuming that's not what you meant (it is a lot easier > > on the eye and a better separation of presentation from your actual > > code). > > > Fred > > > > Phil > > > > On Mar 1, 7:31 pm, Frederick Cheung > > > wrote: > > > > > On Mar 1, 5:10 pm, phil7085 wrote: > > > > > > So then do I need to use the controller to populate another @advert > > > > > object with all the params then render the partial? > > > > > Well I don't know exactly what this controller is trying to do at all. > > > > Assuming what it's doing is create a new object then the controller > > > > code is almost exactly the same as a regular create action, the only > > > > difference is that instead of redirecting to the show action you're > > > > rendering a partial for the object you've just created. > > > > > Fred > > > > > > Cheers, > > > > > > Phil > > > > > > On Mar 1, 5:00 pm, Frederick Cheung > > > > > wrote: > > > > > > > On Mar 1, 1:04 pm, phil7085 wrote: > > > > > > > > I've been trying to create a simple form which when a user enters > > > > > > > any > > > > > > > data that data is displayed as a preview elsewhere on the page > > > > > > > instantly, just like when creating an advert with Google Adwords, > > > > > > > the > > > > > > > preview is shown. > > > > > > > > I've been using form_remote_for and observe_form but I don't seem > > > > > > > to > > > > > > > be having much luck at all. I am unsure how to use the controller > > > > > > > to > > > > > > > get the form fields and pass them back to a partial to be > > > > > > > rendered? > > > > > > > In this respect it's much like a normal form, eg the title will be > > > > > > params[:advert][:title] (assuming @advert is of class Advert). As > > > > > > usual you can just looking at development.log to see what the > > > > > > parameters look like. > > > > > > > Fred > > > > > > > > Here is my form: > > > > > > > > <% form_remote_for @advert do |a| %> > > > > > > > Title: <%= a.text_field :title %> > > > > > > > > > > > > > > First Line: <%= a.text_field :first_line %> > > > > > > > > > > > > > > Second Line: <%= a.text_field :second_line %> > > > > > > > > > > > > > > Visible URL: <%= a.text_field :visible_url %> > > > > > > > > > > > > > > Destination URL: <%= a.text_field :destination_url > > > > > > > %> > > > > > > > <%= submit_tag 'Submit' %> > > > > > > > <% end %> > > > > > > > > Any help would be great? > > > > > > > > Cheers, > > > > > > > > Phil- Hide quoted text - > > > > > - Show quoted text -- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Ajax in Rails
Thanks Fred, How would I then need to tell rails to use the @advert object because that's the part that I have been having trouble with? Phil On Mar 1, 7:41 pm, Frederick Cheung wrote: > On Mar 1, 7:38 pm, phil7085 wrote:> I am simply > trying to show what the user enters somewhere else on the > > page as they type it. > > > I did get it to work using render :text => param[:advert][:title] + > > '' + param[:advert][:first_line] .. > > > But I think there should be a more efficient way to do it? > > > Could I do something like this: > > > def preview > > @advert = Advert.new(params[:advert]) > > render :partial => 'advert' > > end > > Something like that is fine (although you'll need to tell rails to use > the @advert object). It's not more efficient in terms of raw cpu > cycles but I'm assuming that's not what you meant (it is a lot easier > on the eye and a better separation of presentation from your actual > code). > > Fred > > > > > Phil > > > On Mar 1, 7:31 pm, Frederick Cheung > > wrote: > > > > On Mar 1, 5:10 pm, phil7085 wrote: > > > > > So then do I need to use the controller to populate another @advert > > > > object with all the params then render the partial? > > > > Well I don't know exactly what this controller is trying to do at all. > > > Assuming what it's doing is create a new object then the controller > > > code is almost exactly the same as a regular create action, the only > > > difference is that instead of redirecting to the show action you're > > > rendering a partial for the object you've just created. > > > > Fred > > > > > Cheers, > > > > > Phil > > > > > On Mar 1, 5:00 pm, Frederick Cheung > > > > wrote: > > > > > > On Mar 1, 1:04 pm, phil7085 wrote: > > > > > > > I've been trying to create a simple form which when a user enters > > > > > > any > > > > > > data that data is displayed as a preview elsewhere on the page > > > > > > instantly, just like when creating an advert with Google Adwords, > > > > > > the > > > > > > preview is shown. > > > > > > > I've been using form_remote_for and observe_form but I don't seem to > > > > > > be having much luck at all. I am unsure how to use the controller to > > > > > > get the form fields and pass them back to a partial to be rendered? > > > > > > In this respect it's much like a normal form, eg the title will be > > > > > params[:advert][:title] (assuming @advert is of class Advert). As > > > > > usual you can just looking at development.log to see what the > > > > > parameters look like. > > > > > > Fred > > > > > > > Here is my form: > > > > > > > <% form_remote_for @advert do |a| %> > > > > > > Title: <%= a.text_field :title %> > > > > > > > > > > > > First Line: <%= a.text_field :first_line %> > > > > > > > > > > > > Second Line: <%= a.text_field :second_line %> > > > > > > > > > > > > Visible URL: <%= a.text_field :visible_url %> > > > > > > > > > > > > Destination URL: <%= a.text_field :destination_url %> > > > > > > <%= submit_tag 'Submit' %> > > > > > > <% end %> > > > > > > > Any help would be great? > > > > > > > Cheers, > > > > > > > Phil- Hide quoted text - > > > > - Show quoted text -- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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] Using belongs_to within instance method
Is it possible to use model associations with an instance method? For example, I have: Class Reminder belongs_to :event #and i want to access the event id within a Reminder instance method: def find_event_id id = Event.find(event_id).user.id #this works but im wondering if its possible to do something like: id = this_reminder.event.user.id? end --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Using variable class names, how?
My example used clss not class, ... but sure klass if you prefer. Jeff On Mar 1, 11:32 am, Phlip wrote: > Jeff Lewis wrote: > > def first_last_count(clss) > > Note the tradition there is klass: > > http://google.com/codesearch?q=lang%3Aruby+klass > > Being 'class' is a keyword... > > -- > Phlip --~--~-~--~~~---~--~~ 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: Ajax in Rails
On Mar 1, 7:38 pm, phil7085 wrote: > I am simply trying to show what the user enters somewhere else on the > page as they type it. > > I did get it to work using render :text => param[:advert][:title] + > '' + param[:advert][:first_line] .. > > But I think there should be a more efficient way to do it? > > Could I do something like this: > > def preview > @advert = Advert.new(params[:advert]) > render :partial => 'advert' > end > Something like that is fine (although you'll need to tell rails to use the @advert object). It's not more efficient in terms of raw cpu cycles but I'm assuming that's not what you meant (it is a lot easier on the eye and a better separation of presentation from your actual code). Fred > Phil > > On Mar 1, 7:31 pm, Frederick Cheung > wrote: > > > On Mar 1, 5:10 pm, phil7085 wrote: > > > > So then do I need to use the controller to populate another @advert > > > object with all the params then render the partial? > > > Well I don't know exactly what this controller is trying to do at all. > > Assuming what it's doing is create a new object then the controller > > code is almost exactly the same as a regular create action, the only > > difference is that instead of redirecting to the show action you're > > rendering a partial for the object you've just created. > > > Fred > > > > Cheers, > > > > Phil > > > > On Mar 1, 5:00 pm, Frederick Cheung > > > wrote: > > > > > On Mar 1, 1:04 pm, phil7085 wrote: > > > > > > I've been trying to create a simple form which when a user enters any > > > > > data that data is displayed as a preview elsewhere on the page > > > > > instantly, just like when creating an advert with Google Adwords, the > > > > > preview is shown. > > > > > > I've been using form_remote_for and observe_form but I don't seem to > > > > > be having much luck at all. I am unsure how to use the controller to > > > > > get the form fields and pass them back to a partial to be rendered? > > > > > In this respect it's much like a normal form, eg the title will be > > > > params[:advert][:title] (assuming @advert is of class Advert). As > > > > usual you can just looking at development.log to see what the > > > > parameters look like. > > > > > Fred > > > > > > Here is my form: > > > > > > <% form_remote_for @advert do |a| %> > > > > > Title: <%= a.text_field :title %> > > > > > > > > > > First Line: <%= a.text_field :first_line %> > > > > > > > > > > Second Line: <%= a.text_field :second_line %> > > > > > > > > > > Visible URL: <%= a.text_field :visible_url %> > > > > > > > > > > Destination URL: <%= a.text_field :destination_url %> > > > > > <%= submit_tag 'Submit' %> > > > > > <% end %> > > > > > > Any help would be great? > > > > > > Cheers, > > > > > > Phil- Hide quoted text - > > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Absolute Url with Link_to
On Sun, Mar 1, 2009 at 5:21 AM, tashfeen.ekram wrote: > > i am using link_to to make links. it is gnerating urls relative to the > path of the page. how do i make absolute urls. i tried using only_path > but it does nto seem to work. When you are e.g. in http://www.mysite.com/test/sub/hello (controller: 'test/sub' ; action: 'hello') and want to link to: http://www.mysite.com/home (controller: 'home' ; action: 'index') One way to do it is to use: link_to 'home', '/home' this results in: Home (which is relative to root ('/')) using: link_to 'home', 'home' results in: Home (which the browser translates into http://www/mysite.com/test/sub/home and is not what I wanted) If you want to use it with a reference to the /home controller, use: link_to 'Home', :controller => '/home' >From the api.rubyonrails.org documentation for url_for : If the controller name begins with a slash no defaults are used: url_for :controller => '/home' In particular, a leading slash ensures no namespace is assumed. Thus, while url_for :controller => ‘users‘ may resolve to Admin::UsersController if the current controller lives under that module, url_for :controller => ’/users‘ ensures you link to ::UsersController no matter what. HTH, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Absolute Url with Link_to
On Mar 1, 5:21 am, "tashfeen.ekram" wrote: > i am using link_to to make links. it is gnerating urls relative to the > path of the page. how do i make absolute urls. i tried using only_path > but it does nto seem to work. A few ways that work for me are: link_to 'Home', '/home' # => Home link_to 'Home', 'http://www.mysite.com/home' # => Home link_to 'Home', :controller => '/home' # note the '/' in front of home Home > do i need to use url_for? link_to already uses url_for if I understand well. only_path is used to make URL's relative to the root (first '/') of this URL. Is useful when behind a proxy (e.g. an SSL proxy). Much more info can be found on http://api.rubyonrails.org searching the method: url_for (ActionController::Base) HTH, Peter --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Ajax in Rails
I am simply trying to show what the user enters somewhere else on the page as they type it. I did get it to work using render :text => param[:advert][:title] + '' + param[:advert][:first_line] .. But I think there should be a more efficient way to do it? Could I do something like this: def preview @advert = Advert.new(params[:advert]) render :partial => 'advert' end Phil On Mar 1, 7:31 pm, Frederick Cheung wrote: > On Mar 1, 5:10 pm, phil7085 wrote: > > > So then do I need to use the controller to populate another @advert > > object with all the params then render the partial? > > Well I don't know exactly what this controller is trying to do at all. > Assuming what it's doing is create a new object then the controller > code is almost exactly the same as a regular create action, the only > difference is that instead of redirecting to the show action you're > rendering a partial for the object you've just created. > > Fred > > > > > Cheers, > > > Phil > > > On Mar 1, 5:00 pm, Frederick Cheung > > wrote: > > > > On Mar 1, 1:04 pm, phil7085 wrote: > > > > > I've been trying to create a simple form which when a user enters any > > > > data that data is displayed as a preview elsewhere on the page > > > > instantly, just like when creating an advert with Google Adwords, the > > > > preview is shown. > > > > > I've been using form_remote_for and observe_form but I don't seem to > > > > be having much luck at all. I am unsure how to use the controller to > > > > get the form fields and pass them back to a partial to be rendered? > > > > In this respect it's much like a normal form, eg the title will be > > > params[:advert][:title] (assuming @advert is of class Advert). As > > > usual you can just looking at development.log to see what the > > > parameters look like. > > > > Fred > > > > > Here is my form: > > > > > <% form_remote_for @advert do |a| %> > > > > Title: <%= a.text_field :title %> > > > > > > > > First Line: <%= a.text_field :first_line %> > > > > > > > > Second Line: <%= a.text_field :second_line %> > > > > > > > > Visible URL: <%= a.text_field :visible_url %> > > > > > > > > Destination URL: <%= a.text_field :destination_url %> > > > > <%= submit_tag 'Submit' %> > > > > <% end %> > > > > > Any help would be great? > > > > > Cheers, > > > > > Phil- Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ 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: Find or select across a many to many relationship
On Mar 1, 5:52 pm, johnsonmlw wrote: > I have an incident model and a pupil model, and they have a many to > many relationship through an involvement model. Also, a pupil belongs > to a cohort. > > How can I show incidents (ideally just once), in date order, where > there is an involvement present from a pupil where their > pupil.cohort_id == 1 ? One way would be something like Incident.find :all, :joins => :pupil, :conditions => ["pupils.cohort_id = ?", 1] This joins the pupils table (AR is smart enough to know that in needs to join the involvements tables as well) and then you can easily apply conditions on pupils order stuff etc... You'll need to put a distinct in there not to get duplicate rows. > > At the moment, I'm finding all pupils where pupil.cohort_id ==1, then > iterating through the @pupils, listing the involvements/incident > details for those pupils. But this isn't great, as (i) incidents show > up more than once where two pupils are involved in the incident, and > (ii) I can't order by incident date. It feels backwards. > > I suspect maybe I can use > > @incidents = Incident.find(:all) > @incidents = @incidents.select {|i| ... something something to do with > involvements then pupil.cohort_id == 1? Anything that starts with Foo.find(:all) will run out of steam when there starts to be a large number of foos. Fred > > Maybe I'm miles off? > > Help or clues appreciated. --~--~-~--~~~---~--~~ 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: Using variable class names, how?
Jeff Lewis wrote: > def first_last_count(clss) Note the tradition there is klass: http://google.com/codesearch?q=lang%3Aruby+klass Being 'class' is a keyword... -- Phlip --~--~-~--~~~---~--~~ 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: Ajax in Rails
On Mar 1, 5:10 pm, phil7085 wrote: > So then do I need to use the controller to populate another @advert > object with all the params then render the partial? > Well I don't know exactly what this controller is trying to do at all. Assuming what it's doing is create a new object then the controller code is almost exactly the same as a regular create action, the only difference is that instead of redirecting to the show action you're rendering a partial for the object you've just created. Fred > Cheers, > > Phil > > On Mar 1, 5:00 pm, Frederick Cheung > wrote: > > > On Mar 1, 1:04 pm, phil7085 wrote: > > > > I've been trying to create a simple form which when a user enters any > > > data that data is displayed as a preview elsewhere on the page > > > instantly, just like when creating an advert with Google Adwords, the > > > preview is shown. > > > > I've been using form_remote_for and observe_form but I don't seem to > > > be having much luck at all. I am unsure how to use the controller to > > > get the form fields and pass them back to a partial to be rendered? > > > In this respect it's much like a normal form, eg the title will be > > params[:advert][:title] (assuming @advert is of class Advert). As > > usual you can just looking at development.log to see what the > > parameters look like. > > > Fred > > > > Here is my form: > > > > <% form_remote_for @advert do |a| %> > > > Title: <%= a.text_field :title %> > > > > > > First Line: <%= a.text_field :first_line %> > > > > > > Second Line: <%= a.text_field :second_line %> > > > > > > Visible URL: <%= a.text_field :visible_url %> > > > > > > Destination URL: <%= a.text_field :destination_url %> > > > <%= submit_tag 'Submit' %> > > > <% end %> > > > > Any help would be great? > > > > Cheers, > > > > Phil --~--~-~--~~~---~--~~ 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: Using variable class names, how?
Instead of passing class names as strings, why not ref the classes themselves? Lame example, but ... something like: ... def first_last_count(clss) return [clss.find(:first), clss.find(:last), clss.count] end ... first_car,last_car,count_cars = first_last_count(Car) ... first_bike,last_bike,count_bikes = first_last_count(Bike) ... Jeff On Feb 28, 1:27 pm, ms wrote: > Hello, > > I've got some code, which I would like to reuse. The only difference > between the usages are the class names and therefore the different > objects. How would you manage this? Is there a way to take the class > names as strings? Do you know other solutions, a suitable pattern, for > example? > > Thanx for any suggestions! > > Best regards, ms --~--~-~--~~~---~--~~ 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] Find or select across a many to many relationship
I have an incident model and a pupil model, and they have a many to many relationship through an involvement model. Also, a pupil belongs to a cohort. How can I show incidents (ideally just once), in date order, where there is an involvement present from a pupil where their pupil.cohort_id == 1 ? At the moment, I'm finding all pupils where pupil.cohort_id ==1, then iterating through the @pupils, listing the involvements/incident details for those pupils. But this isn't great, as (i) incidents show up more than once where two pupils are involved in the incident, and (ii) I can't order by incident date. It feels backwards. I suspect maybe I can use @incidents = Incident.find(:all) @incidents = @incidents.select {|i| ... something something to do with involvements then pupil.cohort_id == 1? Maybe I'm miles off? Help or clues appreciated. --~--~-~--~~~---~--~~ 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: script/console using older Rails version
This did the trick.thanks!! Craig Demyanovich wrote: > Maybe at some point you put Rails 2.1.0 into vendor/rails. Anything in > vendor/rails will override what you set in environment.rb and what gems > you > have installed. You could delete the vendor/rails directory if you don't > want it, or you could try freezing your app to Rails 2.2.2 and rerunning > rake rails:update. > > Regards, > Craig > > > -- > Craig Demyanovich > Mutually Human Software > http://mutuallyhuman.com -- 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: ssl certificate
Hi, Please explain , what you trying to say ? On Feb 28, 8:45 pm, Conrad Taylor wrote: > On Sat, Feb 28, 2009 at 7:28 AM, Ashikali Ashikali < > > rails-mailing-l...@andreas-s.net> wrote: > > > Can anyone tell me which is best either self-signed or VeriSign > > certificate ? > > > cheers, > > ashikali > > Hi, can you please explain what you're trying to do? > > -Conrad --~--~-~--~~~---~--~~ 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] Strange behavior of Source.column_names
I have a class named Source and a controller named SourceController etc. When I use Source.column_names in the view all names except names ending in _id is listed, although according to the documentation all names should be listed When I use Source.column_names in the source controller it lists correctly all names also the ones ending in id. When I first call Source.column_names in the controller then it lists all names also in the view when I use Source.column_names. Is this a bug in rails ? Is the calls Source reserved ? Has anyone had the same problem ? Is there anyway to solve this problem in a better way than the fisx I use by first calling Source.column_names in the controller ? --~--~-~--~~~---~--~~ 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: Ajax in Rails
So then do I need to use the controller to populate another @advert object with all the params then render the partial? Cheers, Phil On Mar 1, 5:00 pm, Frederick Cheung wrote: > On Mar 1, 1:04 pm, phil7085 wrote: > > > > > I've been trying to create a simple form which when a user enters any > > data that data is displayed as a preview elsewhere on the page > > instantly, just like when creating an advert with Google Adwords, the > > preview is shown. > > > I've been using form_remote_for and observe_form but I don't seem to > > be having much luck at all. I am unsure how to use the controller to > > get the form fields and pass them back to a partial to be rendered? > > In this respect it's much like a normal form, eg the title will be > params[:advert][:title] (assuming @advert is of class Advert). As > usual you can just looking at development.log to see what the > parameters look like. > > Fred > > > Here is my form: > > > <% form_remote_for @advert do |a| %> > > Title: <%= a.text_field :title %> > > > > First Line: <%= a.text_field :first_line %> > > > > Second Line: <%= a.text_field :second_line %> > > > > Visible URL: <%= a.text_field :visible_url %> > > > > Destination URL: <%= a.text_field :destination_url %> > > <%= submit_tag 'Submit' %> > > <% end %> > > > Any help would be great? > > > Cheers, > > > Phil --~--~-~--~~~---~--~~ 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 using nested objects in a test
On Mar 1, 5:01 pm, Heinz Strunk wrote: > So there's no method to create the hash the way it'd be accepted? Sounds > like a helper method... :) Well given an activerecord object then foo.attributes is a hash of attributes, however this cannot anticipate how you're handling things in the controller (eg nationality/nationality_id and the thing you're doing with dates) Fred > -- > Posted viahttp://www.ruby-forum.com/. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~--~~~~--~~--~--~---
[Rails] Re: Problems using nested objects in a test
So there's no method to create the hash the way it'd be accepted? Sounds like a helper method... :) -- 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: Ajax in Rails
On Mar 1, 1:04 pm, phil7085 wrote: > > I've been trying to create a simple form which when a user enters any > data that data is displayed as a preview elsewhere on the page > instantly, just like when creating an advert with Google Adwords, the > preview is shown. > > I've been using form_remote_for and observe_form but I don't seem to > be having much luck at all. I am unsure how to use the controller to > get the form fields and pass them back to a partial to be rendered? > In this respect it's much like a normal form, eg the title will be params[:advert][:title] (assuming @advert is of class Advert). As usual you can just looking at development.log to see what the parameters look like. Fred > Here is my form: > > <% form_remote_for @advert do |a| %> > Title: <%= a.text_field :title %> > > First Line: <%= a.text_field :first_line %> > > Second Line: <%= a.text_field :second_line %> > > Visible URL: <%= a.text_field :visible_url %> > > Destination URL: <%= a.text_field :destination_url %> > <%= submit_tag 'Submit' %> > <% end %> > > Any help would be great? > > Cheers, > > Phil --~--~-~--~~~---~--~~ 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 using nested objects in a test
On Mar 1, 3:31 pm, Heinz Strunk wrote: > Hey, > > I'm having some problems testing the creation of objects with nested > objects. First of all, the test itself: > def test_should_create_user > assert_difference('User.count') do > post :create, :user => { > :character => characters(:user_controller_test), > :username => 'test123', > :password => 'test123', :password_confirmation => 'test123', > :email => 'test...@brothelking.de' } > end > assert_redirected_to > end > > My problem is, that :character has an object as value and converting it > to an arraay with .to_a doesn't really help cause the create method in > the Users controller looks like: > @nationality = Nationality.find(params[:character][:nationality]) > params[:character][:nationality] = @nationality > params[:character][:birthday] = > Date.strptime(params[:character][:birthday], '%d.%m.%Y').to_s(:db) > @user = User.new(params[:user]) > @character = Character.new(params[:character]) > @user.character = @character > > When I convert the characters(:user_controller_test) to an array it has > :nationality_id as a value but not :nationality as I'd have it when I > was using a normal form. > > Does anyone know how I could solve that problem? It's up to you to create the sort of hash that would have been submitted normally. If the way your controller and test data work means that you have to spell that our at :character => {:nationality => characters(:user_controller_test).something.something ...} then you've just got to get on with it 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: Using variable class names, how?
On Mar 1, 4:26 pm, ms wrote: > Hey, no problem, thank you for taking time! :) > Is "Foo".constantize what you're looking for ? Fred > -- ms --~--~-~--~~~---~--~~ 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] Ajax in Rails
Hi All, New to the group, and new to learning rails. I'm having some trouble, i've done a few tutorials on creating some small apps with rails and am now starting to play around myself. I've been trying to create a simple form which when a user enters any data that data is displayed as a preview elsewhere on the page instantly, just like when creating an advert with Google Adwords, the preview is shown. I've been using form_remote_for and observe_form but I don't seem to be having much luck at all. I am unsure how to use the controller to get the form fields and pass them back to a partial to be rendered? Here is my form: <% form_remote_for @advert do |a| %> Title: <%= a.text_field :title %> First Line: <%= a.text_field :first_line %> Second Line: <%= a.text_field :second_line %> Visible URL: <%= a.text_field :visible_url %> Destination URL: <%= a.text_field :destination_url %> <%= submit_tag 'Submit' %> <% end %> Any help would be great? Cheers, Phil --~--~-~--~~~---~--~~ 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 Magazine - Issue #1 is now available
I am happy to announce the very first issue of Rails Magazine! This edition has 36 pages full of quality content, is printed in glossy full-color and can be ordered in US, UK and Canada. The paper is FSC certified for minimal environment impact. The free digital edition (PDF) is well underway and will be available globally in about 2 weeks. I would like to thank everyone who contributed to the magazine, and invite others to do the same. Please visit our web site for previews and additional details: http://railsmagazine.com If you like the idea of a high-quality, free Ruby and Rails publication, please help us promote Rails Magazine. Tweet, blog, link to us, join us on Facebook and otherwise spread the word: http://railsmagazine.com/share! Thank you, Olimpiu Metiu Editor | Rails Magazine --~--~-~--~~~---~--~~ 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: Regular Expression question
Hi. I just tested the regexp against 19. and it works, but I got a little problem with the [\s\n]I just solved: s = '19. / 482.600 mm / 19.06 / 482.600 mm' s.gsub!(/(\.0?[^0])?0+/, '\1').gsub!(/\.([\s\n])/, '\1') This produces: '19 / 482.6 mm / 19.06 / 482.6 mm' The "insignificant" trailing zeros after are always trimmed after a decimal point. Pepe On Feb 28, 6:30 pm, Matt Jones wrote: > There appear to be some good solutions here, but I thought I'd jump > in > with a bit of non-Rails technical detail. > > I'd double check with the source of this data - the zeros may be > significant. > (seehttp://en.wikipedia.org/wiki/Significant_figures) > > The data given doesn't seem to match that (482.600 mm would be written > as > 19."), but it doesn't hurt to verify... > > --Matt Jones > > On Feb 27, 2:47 pm, northband wrote: > > > Hi - > > > I would like to use gsub() to strip decimals with trailing zeros from > > a string. My string looks like this: > > -- > > 19.0 " / 482.600 mm > > -- > > > I would like to end up with this: > > -- > > 19 " / 482.6 mm > > -- > > > Anyone have a regular expression that can do this? > > > 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-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: permalink_fu - update existing records?
Maurício Linhares wrote: > No one can really help you without looking at your code. > > - > Maur�cio Linhares > http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ > (en) > > > > On Sun, Mar 1, 2009 at 11:06 AM, Rails List The question is not about my code. Its about how to use permalink_fu to an existing project. More specifically, how to update existing models ( updating permalink_fu column for the existing records ) have you used permalink_fu before?. -- 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: Using variable class names, how?
Hey, no problem, thank you for taking time! :) -- ms --~--~-~--~~~---~--~~ 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: Using variable class names, how?
Sorry. but i'm completely clueless. Can't really understand what you're trying to say/do. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sun, Mar 1, 2009 at 11:15 AM, ms wrote: > > Thanks for your answer, I read the thread, but this did not really > help me. It's not just about redefining some core methods. I think, > the description of my problem was not clear enough, sorry for this. I > would appreciate, if you could have a look at the following > explanation. > > I've got several entities saved in my database: E1, E2 ... En. All > these entities can be flexibly annotated, so I've got the following > models: > > E1 (Entity) => The entity itself > EA1 (EntityAnnotation) => The various entity annotations, may be > nested > -- > ET (EntityType) => The used entity type which tells something about > the used datatype, display properties, etc. > > This group of models repeat themselves for each exposed entity, so > I've got: > > E1..n > EA1..n > -- > ET > > Now comes the point, I was originally refering to: > > I created some code which checks, if the given annotation type can be > applied to the entity, what kind of sub-entities (children) the > annotation might can have and how much of them and then save them to > the entity annotation table. Here's some pseudo-code for this: > > 1: fetch all annotations / attributes which should be attached to a > entity (those data comes from html formular) > 2: check, whether the given annotations can be applied to the entity > and if they have the correct value type > 3: if there are sub-annotations, check whether they are valid and do > not exceed the maximum of allowed children and if they also have the > correct value type > 4: (check more various constraints...) > 5: (maybe, some more stuff to do...) > 6: if there's no error, save the annotations with the given types and > values > > As I want to save alle entites separately for some kind of reason, I > come to this (refering to the pseudo code above): > > 1: fetch the data > 2: validate given annotations regarding E1 > 3: validate given annotation children regarding E1 > 4: ... > 5: ... > 6: no error: save E1 and all corresponding EA1 > > For the next entity I would repeat all the stuff, just changing the > class names / object names, but gaining all the logic. The point is, > that I don't want to use some kind of case distinction directly in the > code. > > The class using this modul should just define a string constant > defining which entity class / entity annotation class to use. I just > need a possibility to handle class names as string an vice versa like > I do when using the core "send(meth_name, attr, &block)" method. > > I hope, this explanation is adequate. > > Thanx for your help! > > Best regards, ms > > > --~--~-~--~~~---~--~~ 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] atom_builder and link element
I'm using the atom builder to build a feed. It's mostly working but the value in the link element of each entry is not being generated as it needs to be. My url scheme looks like http://example.com/blog/nickname/id I have a controller called blog_entries and a routes.rb file which a seet of maps for blog_entries, it looks something like this (amongst all the other routes): map.blog_entries 'blog/:nickname', :controller => "blog_entries", :action => "index", :conditions => {:method => :get} map.formatted_blog_entries 'blog/:nickname.:format', :controller => "blog_entries", :action => "index", :conditions => {:method => :get} In my views, to generate the correct URLs for links I do something like: <%= link_to 'New Entry', new_blog_entry_path(:nickname => @blog.nickname) %> and this creates the correct path. The builder code looks like: feed.entry(post) do |entry| entry.title post.title etc... end The problem is the generated link in the atom output, it looks like http://example.com/blog/1"; /> when what I need is http://example.com/blog/nickname/1"; /> I've tried entry.link :href => "some other url" but that adds a second link entry into the output which is in the wrong place in the XML so is ignored by readers. So, can I hook into the url generation mechanism to get the nickname value into the URL, or can I tell the builder to use "nickname" when generating the url? If not I guess the other thing is to generate the atom feed myself, seems a shame not to use the builder though. --~--~-~--~~~---~--~~ 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: permalink_fu - update existing records?
No one can really help you without looking at your code. - Maurício Linhares http://alinhavado.wordpress.com/ (pt-br) | http://blog.codevader.com/ (en) On Sun, Mar 1, 2009 at 11:06 AM, Rails List wrote: > > i am experimenting to use permalink_fu to provide clean urls. To begin > with, I have installed it and made necessary changes to models, routes > etc. As I have existing records in table, I wanted to update its > permalink column. So in console, I gave > > Category.find(:all).each(&:save) --as specified by some article > > permalink column gets updated with some crypted like string, like the > ones given below. > > 43c87da01925d7479495cf2617c52c70f18d444f > 8012221562396cf8562fa4bf6b12d0a0ba23d528 > > url links use this as in > > domain.com/category/8012221562396cf8562fa4bf6b12d0a0ba23d528 > > any help is highly 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-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 using nested objects in a test
Hey, I'm having some problems testing the creation of objects with nested objects. First of all, the test itself: def test_should_create_user assert_difference('User.count') do post :create, :user => { :character => characters(:user_controller_test), :username => 'test123', :password => 'test123', :password_confirmation => 'test123', :email => 'test...@brothelking.de' } end assert_redirected_to end My problem is, that :character has an object as value and converting it to an arraay with .to_a doesn't really help cause the create method in the Users controller looks like: @nationality = Nationality.find(params[:character][:nationality]) params[:character][:nationality] = @nationality params[:character][:birthday] = Date.strptime(params[:character][:birthday], '%d.%m.%Y').to_s(:db) @user = User.new(params[:user]) @character = Character.new(params[:character]) @user.character = @character When I convert the characters(:user_controller_test) to an array it has :nationality_id as a value but not :nationality as I'd have it when I was using a normal form. Does anyone know how I could solve that problem? One more thing.. I've got many nested objects in User that's why I need to create @nationality and @character in order to create @user and actually save it. Is there a more convenient way of doing this than I do it above? 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: how to change sqlite3 to mysql..??
On Sat, Feb 28, 2009 at 9:26 PM, haneef5k wrote: > Can u tell me,? which editor is best for Ruby on Rails..apps?? The one you're most proficient with :-) At various times I use jEdit, NetBeans and vi for Rails development, all reasonably cross-platform so I don't have to switch mental gears too much going between Linux and Mac. YMMV, -- Hassan Schroeder hassan.schroe...@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-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: script/console using older Rails version
Maybe at some point you put Rails 2.1.0 into vendor/rails. Anything in vendor/rails will override what you set in environment.rb and what gems you have installed. You could delete the vendor/rails directory if you don't want it, or you could try freezing your app to Rails 2.2.2 and rerunning rake rails:update. Regards, Craig -- Craig Demyanovich Mutually Human Software http://mutuallyhuman.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: script/console using older Rails version
I just tried, but no luck unfortunately. :-( Thanks anyway for the help! Andrew Timberlake wrote: > On Thu, Feb 26, 2009 at 5:50 PM, Dantelepoole Dantelepoole > wrote: >> Strange... >>> "I have never let my schooling interfere with my education" - Mark Twain >> >> -- >> Posted via http://www.ruby-forum.com/. >> >> > >> > > Interesting, have you run rake rails:update ? > After that, I'm out of ideas > > Andrew Timberlake > http://ramblingsonrails.com > http://www.linkedin.com/in/andrewtimberlake > > "I have never let my schooling interfere with my education" - Mark Twain -- 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: Using variable class names, how?
Thanks for your answer, I read the thread, but this did not really help me. It's not just about redefining some core methods. I think, the description of my problem was not clear enough, sorry for this. I would appreciate, if you could have a look at the following explanation. I've got several entities saved in my database: E1, E2 ... En. All these entities can be flexibly annotated, so I've got the following models: E1 (Entity) => The entity itself EA1 (EntityAnnotation) => The various entity annotations, may be nested -- ET (EntityType) => The used entity type which tells something about the used datatype, display properties, etc. This group of models repeat themselves for each exposed entity, so I've got: E1..n EA1..n -- ET Now comes the point, I was originally refering to: I created some code which checks, if the given annotation type can be applied to the entity, what kind of sub-entities (children) the annotation might can have and how much of them and then save them to the entity annotation table. Here's some pseudo-code for this: 1: fetch all annotations / attributes which should be attached to a entity (those data comes from html formular) 2: check, whether the given annotations can be applied to the entity and if they have the correct value type 3: if there are sub-annotations, check whether they are valid and do not exceed the maximum of allowed children and if they also have the correct value type 4: (check more various constraints...) 5: (maybe, some more stuff to do...) 6: if there's no error, save the annotations with the given types and values As I want to save alle entites separately for some kind of reason, I come to this (refering to the pseudo code above): 1: fetch the data 2: validate given annotations regarding E1 3: validate given annotation children regarding E1 4: ... 5: ... 6: no error: save E1 and all corresponding EA1 For the next entity I would repeat all the stuff, just changing the class names / object names, but gaining all the logic. The point is, that I don't want to use some kind of case distinction directly in the code. The class using this modul should just define a string constant defining which entity class / entity annotation class to use. I just need a possibility to handle class names as string an vice versa like I do when using the core "send(meth_name, attr, &block)" method. I hope, this explanation is adequate. Thanx for your help! Best regards, ms --~--~-~--~~~---~--~~ 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] permalink_fu - update existing records?
i am experimenting to use permalink_fu to provide clean urls. To begin with, I have installed it and made necessary changes to models, routes etc. As I have existing records in table, I wanted to update its permalink column. So in console, I gave Category.find(:all).each(&:save) --as specified by some article permalink column gets updated with some crypted like string, like the ones given below. 43c87da01925d7479495cf2617c52c70f18d444f 8012221562396cf8562fa4bf6b12d0a0ba23d528 url links use this as in domain.com/category/8012221562396cf8562fa4bf6b12d0a0ba23d528 any help is highly 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-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: Undefined method 'insert_record' on ActiveRecord save
I've got the same problem "Undefined method 'insert_record'". Could you solve that 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: sortable_element helper query
Why not call a controller action which, in turn calls your model methods and saves? Check out Railscast 147 - Ryan explains how to create a quick sortable list: http://railscasts.com/episodes/147-sortable-lists --~--~-~--~~~---~--~~ 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: what's wrong with this applet tag (trying to get an applet rendering in a RoR page)
It's been a long time since I used Applets, but I think the problem is the use of CODEBASE with ARCHIVE. With CODEBASE, you're telling the browser that your code should be found as loose class files in the /applet directory rather than in the ARCHIVE. I think what you want is just: On Fri, Feb 27, 2009 at 1:43 AM, Greg Hauptmann < greg.hauptmann.r...@gmail.com> wrote: > Hi, > > Any ideas why this tag: > >codebase="/applet" > archive="JavaLibrary1.jar" > code="org.gregnet.NewJApplet.class" > width=350 height=200> > > > is giving me this error (from Rails standard out) > > ActionController::RoutingError (No route matches > "/applet/org/gregnet/NewJApplet.class" with {:method=>:get}): > > > Any ideas? > > > > > -- > Greg > http://blog.gregnet.org/ > > > > > > --~--~-~--~~~---~--~~ 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: beginners question
Ruud - I hope you don't mind but I emailed you some material on the Prototype and Scriptaculous libraries. Might be in your junk mail box? On Feb 28, 9:18 pm, ruud wrote: > Hi Gavin, > > I tried your suggestion; this time the javascript function isn't > called at all. > > <% form_tag({}, {:id => 'radioform'}) do %> > <%= radio_button_tag( 'datum', 'geen', @geendatum ) > %> > <%= f.label( 'geen datum' ) %> > <%= radio_button_tag( 'datum', 'met', !...@geendatum) %> > <%= f.label( 'met datum' ) %> > <% end %> > <%= observe_form( :radioform, :function => 'datum_geklikt > (true)') %> > > It appears that the observe_form results in a error on the error > console: > > Error: $(form) is null > Source file: /javascripts/prototype.js . > > I have a feeling I am sticking my head into a wasp nest. I am really > interested in understanding what happens, but maybe I should begin > with the regular stuff. I appreciate your help Gavin. If I have time > this week to have a look at it again and I find an answer to this > problem, I will put it in this thread. > > thanks, RUud --~--~-~--~~~---~--~~ 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: i18n date formatting rails 2.2.2
On Feb 28, 11:58 pm, Maurício Linhares wrote: > They didn't worke for me either, so I rewrote the to_s method for > dates and times: > > Date.class_eval do > > def to_s( format_name = :default ) > format = case format_name > when String > self.strftime( format ) > when Symbol > I18n.localize( self, :format => format_name) > end > end > > end > > Time.class_eval do > > def to_s( format_name = :default ) > format = case format_name > when String > self.strftime( format ) > when Symbol > I18n.localize( self, :format => format_name) > end > end > > end Great! Thanks, this works for me. (Small bug: parameter to strftime should be format_name, not format). > I did also search for reasons why it doesn't work (from the I18N docs > it seemed that it should work), but this method at the Date object > shows that it has no idea about I18N: > > def to_formatted_s(format = :default) > if formatter = DATE_FORMATS[format] > if formatter.respond_to?(:call) > formatter.call(self).to_s > else > strftime(formatter) > end > else > to_default_s > end > end Yeah I dug up this piece of source code as well. Guess I was too tired to compare this with for instance number_to_currency's source and come to this conclusion myself ;) Anyway, thanks again! Ronald --~--~-~--~~~---~--~~ 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] String ID -> schema.rb incorrect?
Hi, I made one of my ID columns a string, because I don't want my IDs to be guessable (I use a md5 hash of some system parameters with rehashing in case of collisions.) My migration reads: ... change_column :users, :id, :string change_column :comments, :user_id, :string Afterwards executing this my db/schema.rb looks like this: ... create_table "comments", :force => true do |t| t.integer "commentable_id" t.string "commentable_type" t.string "user_id" t.datetime "date" t.text "body" end #so far so good ... create_table "users", :force => true do |t| t.string "email" t.string "pwd_hash" t.boolean "is_active" t.datetime "last_activity" t.string "pwd_salt" t.string "activation_key" t.datetime "signup_date" end hmm, I consider it a bug, because running the migrations and loading the schema from schema.rb lead to different schemas. What do you think? --~--~-~--~~~---~--~~ 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] My new (ruby, rails, random) blog.
Yea, I hate it when people spam huge lists with random blog posts too. I've started a blogging attempt that has, so far anyway, about 90% Ruby content, most of which is directly related to Rails. Not all of it is dedicated to this, it's not that focused, but I am going to attempt to post small tips as I discover them, and larger posts as I write them. There's a few things on Vmware vs Xen testing, Rails security, and other tidbits there now. If you want to have a look, click on over to http://skandragon.blogspot.com/ and have at it. I might decide to make it a bit more focused, but I'm sort of too lazy to run more than one blog. :) --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-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: Ajax.updater to call app_helper or model method..
It works fine until I start making my application RESTful way... Any clues? How can I debug this issue? Frederick Cheung wrote: > On Mar 1, 2:40�am, Carlos Santana > wrote: >> If I use get method then it does not update the select dropdown (which >> is what it is intended to do). >> >> > Then you must be doing something funny somewhere as (apart from > routing) whether it's a get or a post is pretty much irrelevant (and > semantically get is the correct method to be using here). > > Fred -- 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 -~--~~~~--~~--~--~---