[Rails] Is there any problem extend ApplicationHelper in application controller
Hi I have a function in ApplicationHelper say an example def url_needed if current_user.is_staff? home_url else another_url end end And in ApplicationController what I did is def check_for_the_feature flash[:notice] = 'You have no permission to do this.' self.extend ApplicationHelper redirect_to url_needed end Is there any problem extending helper like this. 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] how to convert Date to this json format
Hi I have to create a json date like {"startDate":"\/Date(1291145744713-0700)\/","endDate":"\/Date(1293824144713-0700)\/"} This is just an example. My case startdate = Time.now-2.day enddate = Time.now I dont know how to convert this to the above format. Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] how to handle admin section of a saas application
Hi Mine is a sass model application. Various companies can register. Each company has there own admin and ordinary staff and respective actions etc. I have implemented this with proper privileges,permissions. This is the way till I could manage. My new requirement is a super admin (he can do functionality to any companies. For an example, manually activate account company1's admin user) My question is what approach should I take to implement this? 1) Implement all functionalities of this super admin to a super admin name space. If I follow this approach will there be a lot of code duplication? 2) Treat this super admin as another system user (For example my existing user types are company_admin, staff) and give him privilege and permissions to the required actions. This two ways come into my mind. Is there any other approaches? Please give me some insights on this 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: ActiveRecord::Relation
Hi Then how can I check that it is not triggering sql. I did not understand it properly. Could you explain more please? Frederick Cheung wrote in post #991438: > On Apr 7, 10:49am, Tom Mac wrote: >> Hi Fred >> Thanks . I tried from sample application also like >> def index >> @articles = Article.where(:hidden => true) >> puts @articles.inspect >> - >> end >> >>Here also the query executed. I dont know why. > > because you called inspect on @articles > > 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] Re: ActiveRecord::Relation
Hi Fred Thanks . I tried from sample application also like def index @articles = Article.where(:hidden => true) puts @articles.inspect - end Here also the query executed. I dont know why. -- 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: ActiveRecord::Relation
Hi i am talking exactly about this. Now only I found this https://rails.lighthouseapp.com/projects/8994/tickets/4476-lazy-loading-broken-since-beta3 I am getting this not only in console but application also. Has anything changed in Rails3.0.5? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] ActiveRecord::Relation
Hi I have just started learning Rails3 (ruby1.92, Rails3.0.5) and watched railscast episode 202. I tried Article.where(:hidden => true) from console. I have a confusion there since the cast says that , the above statement execute query in the view when iterated. I did not understand that. I got result from query in the console it self when executed Article.where(:hidden => true). Please comment 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 secure paypal signature, username and password stored in app_config
Hi I am using app_config.yml exactly like http://railscasts.com/episodes/143-paypal-security Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] How to secure paypal signature, username and password stored in app_config
Hi I store paypal api username, password and signature as simple text in config/app_config.yml. I would like to know whether this can be protected , than just storing it as text which anybody can read from app_config.yml. Thanks Tom -- 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] remove .git folder from svn
Hi I use svn. I have git clone active merchant to vendor/plugin. This I did with a purpose to commit back my changes. But the problem is when I synchronize with svn it takes more time due to .git folder in vendor/plugins/active_merchant. My question is how can I ignore .git folder as well as .gitignore file in vendor/plugins/active_merchant when i synchronize with svn Thanks Tom -- 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: ActiveRecord::StatementInvalid
Thanks for your reply. Meanwhile I have done it. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: ActiveRecord::StatementInvalid
> but in terms of getting your > application running can you not just truncate the string to a valid > length before saving the record? Yes that is possible any way not the best. Relating to this two questions. 1) Is there any other gem than mysql. I found ruby-mysql but could not try since it requires ruby >= 1.8.7 . Mine is 1.8.6 2) In mysql what is the next option than a text field that handles very large data 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] ActiveRecord::StatementInvalid
Hi I am using rails2.2.2 with mysql5.1. I have a text field 'EmailBody'. And when I try to store data more than 65536 (Say for example 65550) in linux it works properly by truncating it to 65536 characters and save successfully to table. But when I test this same application on a windows machine I get the error ActiveRecord::StatementInvalid. I am attaching the error I am getting on a windows machine. Is it a adapter prblem. Please help Thanks in advance Attachments: http://www.ruby-forum.com/attachment/5733/inbox.htm -- 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: rvm and phusion passenger
Hi Thanks for the reply. I followed http://blog.phusion.nl/2010/09/21/phusion-passenger-running-multiple-ruby-versions/ I started with passenger start -a 127.0.0.1 -p 3000 -d And I am getting an error. Complete trace is attached. Please have a look Thanks Attachments: http://www.ruby-forum.com/attachment/5672/error.txt -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] rvm and phusion passenger
I have two rails applications currently running on systemruby which is version 1.8.6. And I am using phusion passenger with apache to run the applications. My new requirement is to run one of the applications in Ruby1.8.7. For that I have set up 1.8.7 with RVM. But I dont know how to modify my existing /etc/httpd/conf/httpd.conf to run one application in Ruby1.8.6 (Sytem ruby) and second one in ruby1.8.7 (from RVM). Please help me Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] paypal chained payment
Hi I want to implement paypal chained payment with adaptive payments API. I am totally new to paypal. Kindly guide me to start with. I have heard of gem active merchant. Can I use that for the purpose? Or any other gems? Also please point me to any examples describing adaptive payment with chained payment using rails. My rails version is 2.3.8 Thanks in advance -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Is this error related to connection pool
Hi My environment is ruby 1.8.6 rails 2.2.2 mysql 5.1 windowsXP I have a very lengthy controller action which fetch mail from pop server. But some times I get error. Mainly three error. And I have to restart the application again to remove this errors. But after some time the same errors again happens 1) Mysql::Error (Can't connect to MySQL server on 'localhost' (10048)): C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:548:in `real_connect' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:548:in `connect' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:198:in `initialize' --etc 2) Mysql::Error (Can't connect to MySQL server on 'localhost' (10055)): etc C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:74:in `mysql_connection' C:/Ruby186/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send' 3) Errno::ENOTCONN (A request to send or receive data was disallowed because the socket is not connected and (when sending on a datagram socket using a sendto call) no address was supplied.): /lib/pop_ssl.rb:535:in `connect' /lib/pop_ssl.rb:535:in `do_start' /lib/pop_ssl.rb:507:in `start' /lib/pop_ssl.rb:382:in `start' Please help to solve this issue -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: phpmyadmin equivalent in ruby
Thanks for you all. Hi Michael Pavling you specified > If you *have* to use it, at least put it somewhere obscure *and* use > some extra layer of protection (through htpasswd or similar). Could you please explain it a bit more? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] phpmyadmin equivalent in ruby
Why I asking this is to avoid php installation on server. Is there any phpmyadmin equivalent in ruby and also can be available as a linux package? Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] max_allowed_packet mysql
Hi I am using rails 2.3.8 with mysql 5.1. In my attachment model the validation was validates_attachment_size :attachment, :less_than => 2.megabytes, :message => "Upload file size should not exceeds 2 MB" And my /etc/my.ini has max_allowed_packet = 16M The above worked perfectly. But now I need file limit size as 10 MB instead of 2 MB. So I changed validation like validates_attachment_size :attachment, :less_than => 10.megabytes, :message => "Upload file size should not exceeds 10 MB" And now when I tried to attach a file with size 9.2 MB it gets stuck for long. No attachment happens. Please help Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] mail server application
I would like to know there is any opensource mail server application in rails. I have found this http://mailr.org/ But seems no recent update to this project. Please suggest an equivalent one Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: commiting doc folder to svn
Hi I was asking about should I commit to svn the folder generated by rake doc:app ie doc/app folder completely -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] commiting doc folder to svn
Hi I would like to know expert opinion on this. Should I commit folders like doc/app into svn? What is the general strategy Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] receive mail with sendmail
Hi Could any one please give links to any blogs (etc) which gives a detailed description on receiving emails to rails application with sendmail. I am using fedora12. I request help on configuring mail server (if needed) or can use mail server of another domain and forward it to my application. Dont know how to, since I am prety new to this. If what I am asking is blunder please excuse Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] wild card modal email forwarding to rails application
Hi May be a long story. Sorry for that.My requirement as this. I have a saas application. The different people can create accounts. Each account holder can create users under them . An example is during account creation one user gives email as "adm...@mydomain.com'. Then after login to application he creates say two users and gives (valid) emails as us...@gmail.com and us...@yahoo.com. At a later stage from the application he send mail to both the above users and they get mail in there gmail and yahoo inboxes. Also what is sent to them etc are stored to db also as a thread. Upto this everything works fine. So coming to my requirement suppose us...@gmail.com replies to this email. Then adm...@mydomain.com gets email in his inbox(This also can be done). And also it has to be reached to my rails application . Dont know how to do this???.And also to be logged to my db. The above is the original requirement. As part of that what I would like to know is can I reply mail to user_thread...@mydomain.com (An example is user_...@mydomain.com) . The thing is user_...@mydomain.com is not a valid email. Like that there may be use...@myexample.com ,use...@myexample.com All these are dynamically created when replying. And what I need is, all these mails has to be reached at mydomain.com and forwarded to my rails application. From there I can get the thread_id from this mail (example 100 from user_...@mydomain.com) and also the mail contents so that everything like subject,body etc can be stored to my db. Dont know I could make you understand my requirement. Please tell if you did not understand. Guide me with your valuable comments Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] slow loading application phusion passenger
Hi I have successfully used phusion passenger with my rails application. But the problem is it takes more time to load the first page. And also if I load a page and wait for some time then again next time it takes more time to load the page. Why this happens? Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sending email with attachments
Hi A detailed requirement of the above is as I have a message model, message_participant model, and attachments model. The relations are message has_many message_participants message has_many attachments attachment using paperclip I am storing in database it self. I have in hand a message object which has subject, body etc. So clearly this message has a sender and many recipients. This I can find out. My requirement is to send each of the message recipients this message with its attachments I have all the data in my hand . What I need is, to send same email with attachments to the recipients Please help Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] sending email with attachments
Hi Could anyone please give an example of sending mails with attachments in rails using actionmailer? I have a user in users table whose attachments is stored in attachments table it self( Relation is user has_many attachments ; attachment belongs_to user). Sender for example is ad...@example.com. suppose user1 has two attachments "test1.pdf" and "test2.doc" Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: find does not raise exception
Hi Edmond Thanks for your reply. The problem is not that. Even it enters in rescue, it does not render :file => "#{RAILS_ROOT}/public/404.html". But it continues execution and I get problem at @messages = message_thread.messages as nil.messages Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] find does not raise exception
Hi I have the code def index @messages = message_thread.messages end private def message_thread begin current_user.message_threads.find(params[:thread_id]) rescue ActiveRecord::RecordNotFound logger.warn "No permission or thread_id nil" render :file => "#{RAILS_ROOT}/public/404.html" end end And even if params[:id] does not have any values I dont get any exception . I can't figureout why. Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: help needed to create a complex form
Hi Thanks for replying.I could do it partially with the following modifications to my models and views message_thread has_many messages accepts_nested_attributes_for :messages message == belongs_to message_thread has_many :document_messages has_many :documents, :through => :document_messages accepts_nested_attributes_for :documents,:reject_if => lambda {|a| a[:attachment].blank?} validates_presence_of :subject No other change. But the problem is from the view I am not selecting any file for upload and not entering values for 'subject' . So surely the validation will fail and rerender my new action . My 'create' action like def create @message_thread = MessageThreads.new(params[:message_thread]) if @message_thread.save flash[:notice] = "Message sent successfully" redirect_to home_url else flash.now[:error] = @message_thread.errors.full_messages.join("") render :action => 'new' end end The problem is now the file_field disappears. What might be the cause?I am struggling with this for hours.Please help Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] upgarde from rails 2.3.5 to rails 2.3.8
Hi I upgraded my rails application rails 2.3.8 from 2.3.5 like below gem install rails -v=2.3.8 Now in environemnt.rb RAILS_GEM_VERSION changed to '2.3.8'. Now when I tried to a previous migration like rake db:migrate VERSION=20100714122104 I got warning like DEPRECATION WARNING: Rake tasks in vendor/plugins/delayed_job/tasks, vendor/plugins/paperclip/tasks, vendor/plugins/seed-fu/tasks, vendor/plugins/simple_captcha/tasks, vendor/plugins/tabs_on_rails/tasks, and vendor/plugins/xss_terminate/tasks are deprecated. Use lib/tasks instead. (called from /usr/lib/ruby/gems/1.8/gems/rails-2.3.8/lib/tasks/rails.rb:10) I would like to know why this message shown? Is it any problem? If it is, how to resolve it? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] help needed to create a complex form
Hi My models are message_thread, message, document (document with attachments I am using paperclip) message_thread has_many messages message == belongs_to message_thread has_many :document_messages has_many :documents, :through => :document_messages document = has_attached_file :attachment, :storage => :database has_many :document_messages has_many :messages, :through => :document_messages What i need is to create a message_thread with one message and that message with 2(or more) attachments. I tried like messages_controller == def new @message_thread = MessageThread.new @message = @message_thread.messages.build end new.html.erb == <%form_for @message_thread, :url => { :action => "create" },:html => {:multipart => true,:class => "mail-tenant"} do |f| %> <%= f.text_field :mail_to %> <% f.fields_for :messages do |message| %> <%= message.label :subject,'Subject' %> <%= message.text_field :subject,:maxlength => 255 %> Attachments: <% message.fields_for :documents do |document| %> <%= document.file_field :attachment,:class => "file" %> <%= document.hidden_field :company_id,:value => current_company.try(:id)%> <%end%> <%end%> Send Or Cancel <%end%> But I am getting error ActiveRecord::AssociationTypeMismatch in MessagesController#create Document(#-614356858) expected, got Array(#-608120208) Please help me to solve this. I have a vague idea of using accepts_nested_attributes_for . But please tell here can I use it Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] An implementation level question
Hi I have a message model and message_participants table. message_participants table because same message goes to various recipients. Messaging between either company to users OR user to company. So an initial design of tables made like messages table --- +---+--+--+-+-++ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | id| int(11) | NO | PRI | NULL| auto_increment | | subject | varchar(255) | YES | | NULL|| | message_thread_id | int(11) | YES | | NULL|| | message | text | YES | | NULL|| | company_id| int(11) | YES | | NULL|| +---+--+--+-+-++ message_participants table +---+--+--+-+-++ | Field | Type | Null | Key | Default | Extra | +---+--+--+-+-++ | id| int(11) | NO | PRI | NULL| auto_increment | | direction_in | tinyint(1) | YES | | NULL|| | direction_out | tinyint(1) | YES | | NULL|| | type | varchar(255) | YES | | NULL|| | company_id| int(11) | YES | | NULL|| | user_id | int(11) | YES | | NULL|| | message_id| int(11) | YES | | NULL|| +---+--+--+-+-++ Here about 'type' field I am not sure. My question is should I treat message_participants like STI or polymorphic? I can't decide it. Relation is message has_many message_participants message_participants belongs_to message Please guide Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] attaching multiple files at a time on a has_many through
Hi My models are class MessageThread < ActiveRecord::Base has_many :messages accepts_nested_attributes_for :messages end class Message < ActiveRecord::Base has_many :message_participants belongs_to :message_thread has_many :document_messages has_many :documents, :through => :document_messages accepts_nested_attributes_for :documents end class Document < ActiveRecord::Base has_attached_file :attachment, :storage => :database default_scope select_without_file_columns_for(:attachment) has_many :document_messages has_many :messages, :through => :document_messages end class DocumentMessage < ActiveRecord::Base belongs_to :message belongs_to :document end I have to make an email compose interface. So my messages controller new and create(sample) action like def new @message_thread = MessageThread.new @message = @message_thread.messages.build end def create MessageThread.create(params[:message_thread]) end And the new form I tried like <%form_for @message_thread, :url => { :action => "create" },:html => {:multipart => true} do |f| %> <%= text_area_tag 'mail_to',nil,:cols => 10, :rows => 3,:style => "height:30px;"%> <% f.fields_for :messages_attributes do |message| %> <%= message.label :subject,'Subject' %> <%= message.text_field :subject,:maxlength => 255 %> <%#=end %> Attachments: <%message.fields_for :documents do |a| %> <%=a.file_field "attachment[]"%> <%=a.file_field "attachment[]"%> <%end%> Send Or Cancel <%end%> And I am getting error NoMethodError in MessagesController#create undefined method `with_indifferent_access' for "":String Please help me to correct this Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] upgrading from rails2.3.5 to rails2.3.8
Hi Please guide me to upgrade my rails application which is 2.3.5 version to 2.3.8 step by step. Thanks for your help Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rails asset cache
Hi Could anybody please clarify my doubt? Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rails asset cache
Hi Again I am facing a problem. I am using firefox with firebug.A portion of my code like <%= stylesheet_link_tag "styles","home", :cache => "cache/all" %> Now in my local machine from firebug under net tab I disabled "Browser cache" .Then result I got like GET home http://localhost:3000/home 200 OK localhost:3000 14.4 KB (?) ... GET styles.css?1279620123 http://localhost:3000/stylesheets/styles.css?1279620123 200 OK ... Again from local machine I enabled "Browser cache" and got result like(Only the below line I got) GET home http://localhost:3000/home 304 Not Modified localhost:3000 14.4 KB ... But the above same procedure when I did from another machine which is not local, I got the same result for both the steps. Caching did not happen. I got 200 OK for both steps. I am running in staging mode. Please help me to resolve this Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] rails asset cache
I have a of line code like <%= stylesheet_link_tag "styles",:cache => "cache/styles" %> And it produces source as config.action_controller.perform_caching = true My concern is what is 1279620123 after question mark(?) above. If such a random number always appended, whether caching in browser happens or not?Please give me a good idea Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] calculate the number of months difference between two dates
Please share if there any such easy methods in rails. I have dates like date1 = Date.today date2 = Date.today - 3.months (Example can be anything) Now how to get month difference as 3 (date1 - date2) Thanks for any help Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] named scope and has_many
Hi I have the models User and Payment. The relation between them user has_many payments payment belongs_to user payments table has a field paid_date. Now for finding out the last paid_date for a particular user I did like class payment < ActiveRecord::Base named_scope :last_payment_date, :select => 'MAX(date_paid) as date_paid' end Then @user = User.find(id) @user.payments.last_payment_date I get the correct answer. But actually is this correct? Because sql generated is SELECT MAX(date_paid) as date_paid FROM `payments` WHERE (`payments`.user_id = 8) AND (`payments`.user_id = 8) I would like to know why (`payments`.user_id = 8) appears twice Thanks -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] papaerclip file name and special characters
Hi I have a problem checking the uniquness of filename. My rails controller code is if params[:document]["attachment"] && (current_user.documents.find(:all).map(&:attachment_file_name).include? params[:document]["attachment"].original_filename) flash[:error] = "File already exists" else #store file --- I am using database storage. Now suppose if I am saving the file cli ent&&list.gif paperclip save the attachemnt_file_name as cli_ent_list.gif Again I am trying to upload the same file and in the above code it goes to the else part and save the file since params[:document]["attachment"].original_filename will be cli ent&&list.gif I cant use validatesuniquness because of some reasons and have to use the above code. Please tell me how can I solve this issue? Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re:
Hi Finally I solved like Add And may I conclude that there is no helper which gives exact raw html like http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re:
Hi You are right. But still the problem. Please help if possible Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re:
Hi Did not get ny reply. Please help. It is urgent Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails]
Hi I would like to construct a button like Add And I used the helper button_to_remote for this like <%= button_to_remote("Add", { :url => some_url(@id), :condition => "check_valid()", :with=> "'ids='+user_ids"}, {:class => "form-button2 fixed3"} ) %> I get the functionality correctly But it produces html like So ignoring css style Please tell me which helper to use to get html like http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] STI and controllers
Hi This is an implementation question. I have the STI models like Class FileCabinet < ActiveRecord::Base end Class TenantFileCabinet < FileCabinet end Class CompanyFileCabinet < FileCabinet end And file_cabinets table is | id | int(11) | NO | PRI | NULL| auto_increment | | company_id | int(11) | YES | | NULL|| | type | varchar(255) | YES | | NULL|| | tenant_id | int(11) | YES | | NULL|| My documents table is below(I use paperclip) |id | int(11) | NO | PRI | NULL| auto_increment | | attachment_file_name| varchar(255) | YES | | NULL| | | attachment_content_type | varchar(255) | YES | | NULL| | | attachment_file_size| int(11) | YES | | NULL| | | attachment_updated_at | datetime | YES | | NULL| | | company_id | int(11) | YES | | NULL| | | attachment_file | longblob | YES | | NULL| | And between file_cabinet and documents there is has_many :through relation. My document_file_cabinets table is | id | int(11) | NO | PRI | NULL| auto_increment | | document_id | int(11) | YES | | NULL|| | file_cabinet_id | int(11) | YES | | NULL|| | deleted | tinyint(1) | YES | | 0 || | company_id | int(11) | YES | | NULL|| | document_name | varchar(255) | YES | | NULL|| My purpose is to add documents to company file cabinet (those can be done and viewed by company admin) and each tenant also have there own file cabinet. To which documents are added by admin. My question is since this an STI which controller should I use and how? Is it file cabinet controller OR company_file_cabinets_controller and tenants_file_cabinets_controller? Please guide me. Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: attachment_fu and paperclip comparison needed
Hi I did not get a reply to this. Any comment please? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] STI
Hi While googling i found this old blog. http://sean-carley.blogspot.com/2006/05/when-rails-needs-clue-single-table.html But the problem specified there still exists with even rails 2.3.5 . Why it is not resolved Any specific cause? Please share your thoughts Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] attachment_fu and paperclip comparison needed
Hi Could anybody please give a comparison on which of these to use? For example in attachment_fu documentation I saw files can be stored finally 4 ways like File system Database file Amazon S3 Rackspace (Mosso) Cloud Files Like that many more. So if a get a proper comparison that will be very beneficial Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sorting a listing page
Hi I still could not get an exact choice. I found this http://www.2dconcept.com/jquery-grid-rails-plugin But suppose if have a column like full_name but it is not a db column ( i have db columns firstname and lastname) then what I will do? If anybody has any other choice than please help. Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: sorting a listing page
Hi In short I am searching the best grid plug/gem in rails Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] sorting a listing page
Hi I have a list page for users. I am using will_paginate for pagination. So an example is full_name(f_name+l_name) email unit(this an integer colum is user.buildng.unit) Clinton Trone cl...@test.com 2 Evette Pace e...@test.com2 Brett B br...@test.com 10 ... My requirement is to sort by any of the headings ie first_name, email or unit on clicking them. Also I need Alphabetical sorting .Like there will be All,A,B,C ...Z,Other in the list page. Then on clicking suppose D the paginated list has to sorted by letter 'D' like that. I have no idea how to implement this. Please help Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: exception handling
Hi Thanks. But how can I handle in code? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] exception handling
Hi I have controller edit action like def edit begin @user = User.find(params[:id]) rescue ActiveRecord::RecordNotFound logger.warn "User with id #{current_user.id} tried to edit user with id #{params[:id]}" render :file => "#{RAILS_ROOT}/public/404.html" else --- end end And suppose if current_user has noa ccess to user with id = 10.Then when try http://localhost:3000/edit/10 This will render the 404.html Now my problem is suppose if the user try something like http://localhost:3000/edi123t/10 Then what I get is a routing error. I dont know how to handle this. Please help. Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: date in a textfield
Hi > MODEL: > class Contract < ActiveRecord::Base > > def formdate_string > formdate.to_s(:db) > end > > def formdate_string=(fdate_str) > self.formdate = Time.parse(fdate_str) > end > > end This happens when in the new does not get value And as one of the post in the railscast page suggest it can be solved with an instance varibale like def formdate_string @formdate_string || (formdate.to_s(:db) unless formdate.nil?) end def formdate_string=(fdate_str) @formdate_string = fdate_str self.formdate = Date.parse(@formdate_string) rescue ArgumentError @formdate_invalid = true end @formdate_invalid can be used in def validate Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: persist the same url even if validation fails
Hi I could solve it by modifying routes like map.connect '/staff_registration/:code', :controller => :staff, :action => :registration_completion,:conditions => { :method => :put } map.staff_registration '/staff_registration/:code', :controller => 'staff', :action => 'registration' And modified action registration_completion like def registration_completion @user = User.find_by_perishable_token!(params[:code]) @staff = @user.staff - ---etc end And also form_for like <% form_for @user, :url => staff_registration_url(:code => params[:code]), :html => {:method => :put} do |f| %> - This problem was there in my mind for months. Now it is solved. Posting it for whom search with similar problem Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: dynamically linking to ajax.googleapis jquery
Hi Joe Thanks for your elaborate answer. It was useful Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] dynamically linking to ajax.googleapis jquery
Hi I am using jquery and jqueryui in my application And in layout I use <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"%> <%= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"; %> <%= stylesheet_link_tag "http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/redmond/jquery-ui.css"; %> My question is, there any problem by linking to css and js like these. I am totally a newbie regarding this? Is this a performance issue in production. And I have one more concern(Dont know I am right) suppose if in any case those sights down then will it fail? What is the normal procedure for doing this? Whether I have to download all the sources to my application? Thanks for your time Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] has_many :through and named_scope
Hi I have the models roles, users and user_roles. The relationship among them is user.r --- user has_many user_roles user has_many roles, :through => :user_roles role.rb === role has_many user_roles role has_many users, :through => :user_roles user_role.rb belongs_to :user belongs_to :role Suppose a login user1 has roles [admin, staff] And login user2 has only one role say [participant] Now how can I check the cases 1)a login user is an admin or staff 2) a login user has_role participant? And also I would like to know whether this can be written using named scopes.(I am totally new to named scopes) Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: captcha in a belongs_to
Hi Anybody please help. This still i can't solve Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] captcha in a belongs_to
Hi I am using simple_captcha. I have two models User and Staff. Relation ship are User has_one staff staff belongs_to user Now in the staff edit I have to include a captcha. I did like <% form_for @user, :url => staff_url(@staff), :html => {:method => :put } do |f|%> <%= f.text_field :first_name,:maxlength => 50 %> <%= show_simple_captcha :image_style => 'random',:distortion => 'medium' %> <%end %> And in staff.rb apply_simple_captcha :message => "Verification code does not match with image." And in update action of of staff controller def update @staff = Staff.find(params[:id]) @user = @staff.user if @staff.valid_with_captcha? and @user.update_attributes(params[:user]) flash[:notice] = "check your mail " redirect_to login_url else flash.now[:error] = @staff.errors.full_messages.join("") #This I wrote deliberately render :action => :edit end end But even I put the correct captcha code and submit , it always shows message "Verification code does not match with image.". Dont know why please help Note: The params are like {"user"=>{"first_name"=>"Tom", "last_name"=>""}, "action"=>"update", "_method"=>"put", "authenticity_token"=>"0OWRFPssTgTqCUESex7LrJ2QQ7HWSiAQxtiMhQm/N1s=", "captcha"=>"PYESEZ", "id"=>"10", "controller"=>"staff"} Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: deciml
Hi Thanks for all your reply Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] deciml
Hi In my table I have t.decimal :rent, :precision => 12, :scale => 2 But when ever I enter a large value like 1234567890333.465 To the table it is stored as 99.99 I would like to know how active record validation can be applied here? Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] date in a textfield
Hi I have two date fields in table start_date and end_date .There data type are datetime. Now in the view I am accepting values of them as text fields like And I am following RailsCast 32 <%= f.text_field :start_date_string, :value => '', :maxlength => 50 %> <%= f.text_field :end_date_string, :value => '', :maxlength => 50 %> And in my model validates_presence_of :start_date def start_date_string start_date.to_s(:db) end def start_date_string=(start_date_str) self.start_date = Time.parse(start_date_str) end def end_date_string end_date.to_s(:db) end def end_date_string=(end_date_str) self.end_date = Time.parse(end_date_str) end But my problem is validates_presence_of :start_date is not working Even if I dont give any values to start date it does not show any error message. Please help Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: To translate this query to railsway
Hi Hitesh > User > has_one :membership > has_one :role, :through => :membership > > Role > has_many :memberships > has_many :users, :through => :memberships > has_many :permissions > has_many :privileges, :through => :permissions > > Membership > belongs_to :user > belongs_to :role > > > Privilege > has_many :permissions > has_many :roles, :through => :permissions > > Permission > belongs_to :privilege > belongs_to :role > Thanks for your reply. All otheres except User are right. User is User has_many :memberships has_many :role, :through => :memberships Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] To translate this query to railsway
Hi I have the tables users, roles, memberships( join table between users and roles. Between users and roles there is has_many :through relation ship) privileges, permissions (join table between roles and privileges. Between roles and privileges there is has_many :through relation ship) privileges table entries like 1 add_user 2 delete_user ,. roles tables entries like 1admin 2participant,. Now to find whether a given user(with id=2) has a privilege like 'add_user' I wrote a query like select memberships.id from memberships inner join permissions on memberships.role_id=permissions.role_id where memberships.user_id=2 and permissions.privilege_id=(select id from privileges where privilege_name ='add_user'); And I get the correct result. Now I would like to know how I can write the above query in an activerecord style.Please help Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: seed_fu and has_many :through
Hi Colin Suppose I have the development phases like phase1,phase2, etc. So for example in Phase1 I have to seed data to say table1 (rake db:seed_fu) And it is deployed. Now again in phase2 again I have to seed data to table2 . Then also to sseed data I run rake db:seed_fu But when ever I run this command it seeds data to table1 (once more) and table2 (for the first time). Is n't it? I think I can answer your question. But could you please give answer to my original questions posted in this thread. Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] seed_fu and has_many :through
Hi In my application to seed data I am using seed_fu (http://github.com/mbleigh/seed-fu) I have tables roles,privileges and permissions( It joins roles and privileges). Now at application startup I have to seed these tables with data. But during runtime some additionals rows may be added to permissions. But I dont how at a later stage if I run rake db:seed_fu all data that I set later to permissions may be wipeout. I dont know how to handle this. As an example role = 1 admin 2 contact 3 employee privilege = 1 add_contact 2 edit_contact 3 delete_employee permissions (role_id,privilege_id) === 1 1 1 2 3 2 .etc Suppose this may be seeded at startup. Later additional entries may go to permissions. One of my question is how can I use seed_fu to fill data for permissions table? Can I do it as usual like create db/fixtures/permission.rb and Permission.seed_many(:id, :id, [ { :role_id => 1, :privilege_id => 1 }, { :role_id => 1, :privilege_id => 2 }, { :role_id => 3, :privilege_id => 2 } ]) One more question is if I follow like above and at a later stage if run rake db:seed_fu again all data that where added later to permission will be lost. And also how can I ensure that all the id values above should be what I expected. Please guide me Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: seed data
Hi Thanks for your reply > Could you explain what you're trying to do in a step by step scenario? > This > may helper others on the mailing list to better assist you. What I tried is as my first post. Now just as a test a I did like State.destroy_all State.create(:id => 1,:name => "Alabama", :abbr => 'AL',:fips => '01', :country_id => 1) But after this step whenever I do rake db:seed_fu I dont get what I expected for the id fields. I expect id to be generated like 1,2,3 > If you really need the id to be pre-defined (though why you need to do > this I do not know, it is generally a bad idea) Why I need the id to be predefined means suppose at a later stage if already that id may e saved to a number of tables as foreign key. But suppose if execute rake db:seed_fu then if the id changed to 5,6,7 instead of 1,2,3 the total solution may be a big fail So when I checked the way which I mentioned in my first post accidently I noticed this. Then post a message to a get a clarification since I dont know where the fault is I think one more thing to ensure the ids are the values that I expected is, after creation call a function like @country.update_id_to(1) . Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: seed data
Hi So my question is how can I ensure that even after running rake db:seed (rake db:seed_fu) a number of times my primary key ie, id here, does not get modified? Should I need to write an update_id function again? Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] seed data
Hi I am using seed_fu to seed initial data to tables (http://github.com/mbleigh/seed-fu) . And in db/fixtures/state.rb I have values like (I am filling only two data for simplicity) State.seed_many(:name, :abbr,:fips,:country_id, [ { :name => "Alberta", :abbr => 'AB',:fips => '01', :country_id => 2 }, { :name => "Alaska", :abbr => 'AK',:fips => '02', :country_id => 1 } ]) It works and when I do select * from states; I get result as +-+--+---+--++ | id | abbr | name | fips | country_id | +-+--+---+--++ | 1 | AB | Alberta | 01 | 2 | | 2 | AK | Alaska| 02 | 1 | But now I modified state.rb as State.seed_many(:name, :abbr,:fips,:country_id, [ { :name => "Alberta", :abbr => 'AB',:fips => '01', :country_id => 2 }, { :name => "Alaska", :abbr => 'AK',:fips => '02', :country_id => 1 } ]) State.destroy_all State.create(:id => 1,:name => "Alabama", :abbr => 'AL',:fips => '01', :country_id => 1) And now when I do select * from states; I get unexpected result as +-+--+---+--++ | id | abbr | name | fips | country_id | +-+--+---+--++ | 5 | AL | Alabama | 01 | 1 | What I expect was id=1 But I got id as 5 . Why this ? Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] attr_accessor as boolean
Hi I have in my user model attr_accessor :no_password_validation_needed with_options :unless => :no_password_validation_needed do |p| p.validates_length_of :password, :minimum => 6 p.validates_confirmation_of :password end And from controller I do @user.no_password_validation_needed = false @user.update_attributes(params[:user]) And it works perfectly and now validation happens. If it is @user.no_password_validation_needed = true Then also I get the expected result as now validation not happens But now when @user.no_password_validation_needed = 2 #or any other value Now I get unexpected result as validation not happens That is same result when true? Why this?What modification should I make?Please help Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Saas design considerations
hi saljamil > and its children. I used named scopes in the model to pass the user_id > from controller and get back data specific to that user (his org and > children orgs). Send me an email if you need some code examples. I would like to get some code examples. Please send your mailid. My id is to.tom.mak at gmail.com Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] h() method in form partial
Hi I have a doubt. Dont know it is valid. Just asking. I am trying to reuse the same partial _form for both new and edit. So from new.html.erb I call partial like <%= render :partial => 'user_fields', :locals => {:f => f}%> and in _user_fields.html.erb an example field as <%= u.label :first_name,'First Name' %> <%= u.text_field :first_name,:maxlength => 50 %> My question is if I call this same partial in edit.html.erb also, how can I apply the h() method like below (since this fields being populated with value from db being an edit form) <%=h u.label :first_name,'First Name' %> <%=h u.text_field :first_name,:maxlength => 50 %> Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how to customize logger messages in rails 2.3.5
Hi > You can overload call method from Formatter. > > example: > > class Logger >class Formatter > Format = "%s [%s] %s %sn" > def call(severity, time, progname, msg) > Format % [severity, format_datetime(time), progname, msg] > end >end > end > > $LOG.error('This is much shorter.') > # ERROR [2006-03-31T19:35:01.058646 ] This is much shorter. > Thanks for your reply. Where should I place this code? In environment.rb or any initializer? Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] how to customize logger messages in rails 2.3.5
Hi I would like to know how I can customize logger message format in rails 2.3.5 Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: how to specify relationship between these models
Hi Lots of thanks for all your reply. What I am finally doing is following. (Is it you people suggested?). I have still problem in creating the view for adding a staff. Please correct me if what I am doing is wrong way. users - name email phone etc staffs -- city state user_id Now in staff controller def new @user = User.new end staff/new.html.erb <% form_for @user,:url => staff_index_url, do |u| %> <%= u.text_field :first_name,:maxlength => 50 %> <% u.fields_for :staff do |s| %> <%= s.text_field :address_street1,:maxlength => 50 %> <%end%> <%= submit_tag "ok"%> <%end%> Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: how to specify relationship between these models
Hi Thanks for your reply. This I have already thought of. But one thing I can't understand is why everything is stored in a single table say users here? Can we store each items for say staff,director etc to there own tables? Or Am I wrong? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] how to specify relationship between these models
Hi I have a user model which I used as authlogic. What I need to implement is I have to add staff also to the system. And I designed tables like users - name email phone etc staffs -- city state user_id My question is is this the right approach? And if yes what would be the relation from users to staffs? I think we can say staff belongs_to user But what is the reverse? Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: rerender a page if validation fails
Hi I get error when I enter http://localhost:3000/users/1 from url But if it is http://localhost:3000/users/1/edit No problem. So my question is why in the else case it shows in the url http://localhost:3000/users/1 instead of http://localhost:3000/users/1/edit Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] rerender a page if validation fails
Hi I have in routes.rb like map.resources :users Now I am trying to edit a user. What the url shows now is http://localhost:3000/users/1/edit But my problem is , when I click on update button and if validations fail I am re rendering the edit page. And it happens properly. But the url becomes http://localhost:3000/users/1 I can't figure it out . Please give a solution. Why this happens? So if a user goes to url and press enter it will show Unknown action No action responded to show. Actions: create, edit, new, and update My controller code for update is def update @user = User.find(params[:id]) respond_to do |format| if @user.update_attributes(params[:user]) flash[:notice] = 'User was successfully updated.' format.html { redirect_to home_url } format.xml { head :ok } else flash.now[:error] = @user.errors.full_messages.join("") format.html { render :action => "edit" } format.xml { render :xml => @user.errors, :status => :unprocessable_entity } end end end Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: xss
> > Life is much easier if you just store what they typed and deal with it > when you use it... And again going through the plugin doc I found an example like class Message < ActiveRecord::Base xss_terminate :except => [ :body ] end Means we can exempt some fields from sanitization. So isn't that sufficient? Any other thoughts? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: Logging in Rails
Hi Colin Thanks for replying back. One more thing I need to clarify is when to use the different levels for logging? For example say in controller we can write logger.info "some thing" or logger.warn "something" How can we know that we should chose this here say info or warn here? Is there any criteria for this? My question may be blunder please excuse. Could you please pont to a good example? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Logging in Rails
Hi Thanks for all reply. When googling I saw this http://toolmantim.com/thoughts/logging_rails_to_syslog_with_sysloglogger Since a beginner I am asking what will be the advantage if using above? And also I would like to know what are the latest happenings like this Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Logging in Rails
Hi I dont know much about logging in rails? Could anybody please explain how to do that in a live application? Or point me to any latest links which gives a detailed description of how to do this for different environments in rails? Why I am asking this is, I don't know where to start. But have a vague idea about the levels info,debug, etc. But dont know how to apply that (Or use it) in my application which is in an initial stage.Please help Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: xss
Hi No comments yet! Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] xss
Hi http://code.google.com/p/xssterminate/ I have found this rails plugin which automatically removes XSS from models upon saving. This is great. My concern is, which is the best choice, 1) use plugin like this Or 2) allow the content to be entered in to db as it is and later escape it from view using h method or sanitize . Why I am asking this is , the latest railscast 204 says rails3 automatically sanitize html. But why cant use this type of plugin for not at all entering such malicious user inputs to the database? Please share your thoughts Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: config.action_mailer.default_url_options = { :host => }
Hi Dieter Your answer, if I undersood correctly is to specify like config.action_mailer.default_url_options = { :host => "localhost:3000" } in enviroment. This is what I do now. But my question is how to make it dynamic. Means some thing like config.action_mailer.default_url_options = { :host => request.host_with_port() } And also only at a single place to make it DRY Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] config.action_mailer.default_url_options = { :host => }
Hi In my application I have a mail sending part in which a user get mail with a link to activate his account. What I am currently doing is as a part of test I created a staging environment And in config/environments/staging.rb I write like config.action_mailer.default_url_options = { :host => "Ip_address_here" } It is working fine And the user get a mail with content say to click http://192.168.0.12/activate/token Now a problem I find is suppose if have to test the same application in another server in another location I have to edit the above to match the IP address of that machine And one more problem is if it is hosted in a public IP a user belong to that network get a mail like say Click http://72.x.x.x/actiavate/token to activate. But it may not work from that network. So agin I have to edit and change it My question: Is this the standard way ?.Please advise me the correct approach to do this. Or Can I use ActionController::Request class for this Thanks in advance Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: to get only the updated fields
Hi I solved it as Michael suggested And it was working .But now i notified another issue. That is why reopening the thread. The issue is, even if the validations fail, mail is sent to user (What I need is only if update happens successfully on changed attributes then only mail to be sent) controller code is @user = User.find(params[:id]) res = @user.update_attributes_and_notify(params[:user]) if res == true do this elsif res == false do this elsif res == 'nochange' do this end User model code is def update_attributes_and_notify(attributes,user) self.attributes = attributes if changed? deliver_user_edit_details! save else return 'nochange' end end and if I change the line in model deliver_user_edit_details! if save I get error undefined method `call' for nil:NilClass What would be the reason? Please help Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: field_error_proc
Hi I can't solve this. could anybody please give a solution? Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: aliased render
I got a solution from another old thread in a different forum like map.login '/login', :controller => 'admin/user_session', :action => 'new', :conditions => { :method => :get } # This line does the trick: map.connect '/login', :controller => 'admin/user_session', :action => 'create', :conditions => { :method => :post } Then in new.html.erb <% form_for @user_session, :url => login_path do |f| %> This is perfectly right. But if I have a route like map.root :controller => "users",:action => "new" And if my form is like <% form_for @user do |f| %> Please guide how I can apply this here. Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: Re: to get only the updated fields
Hi Thank you. I have one more thing to clarify . If I write a before_save filter as you suggested, then will mail be sent when ever there is an update or save to this User model ? That is not what I want if it behaves like that.Please excuse if I am wrong Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] aliased render
Hi In my routes.rb I have map.login '/login',:controller => :user_sessions, :action => :new Now I have controller action as def create @user_session = UserSession.new(params[:user_session]) if @user_session.save redirect_to some_url else render :action => :new,:layout => 'my_layout' end end The problem in the else case when render action new again what I get in browser is http://localhost:3000/user_session But what I need is http://localhost:3000/login Or in the worst case http://localhost:3000/user_sessions/new How can I do this? Please help Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: access authlogic current_user in actionmailer view
Hi I have already tried that. Anyway I could solve it y passing current_user from controller and called that mail sending in model from controller Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: to get only the updated fields
Hi Conrad Thanks for your reply. But this is not working for update_attributes. What I tried is in update action @user = User.find(params[:id]) if @user.update_attributes(params[:user]) send_mail if @user.changed? #But this is always returns false Not working - else end Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] field_error_proc
Hi I have in my environment ActionView::Base.field_error_proc = Proc.new { |html_tag, instance| "#{html_tag}" } It is working perfectly. But what I need is only for the login form I have to change this and need to show only the flash error message. Is this possible. Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] to get only the updated fields
Hi I remember once I read about to get only updated fields from an update_attributes method. Means say I have a model user with name,age,sex etc And when the user updates the information I have to first check whether he actually updated anything(There is a chance that update button from view simply being clicked) and if only any updates happened I have to get that updated fields and send a mail stating that these fields are updated. How can I do this. Suppose in the above example if only name updated Thanks Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
[Rails] Re: access authlogic current_user in actionmailer view
Hi Still I can't solve it.Please help Tom -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.