ruby-on-rails

How to pass object in :with field for a link_to_remote call

I have an object elem that I'd like to pass to the remove_tag_from_cart method. Here is my attempt: -counter.times do |c| -elem = @tags[c] #{elem.name}#{link_to_remote image_tag('x.png'), :url => {:controller => 'questions', :action => 'remove_tag_from_cart'}, :with => {:tag_to_remove => :elem}} The :with clause isn't working corr...

How to install curl on windows for ruby on rails

Hi, I am new to ruby on rails. Could you please help me to install curl. I have windows 7 and ruby 1.8.7 I need to install Paul Dix's FeedZirra. I need curl for that. Also could you help me with gem install curb. Even curb seems to need Curl Looking forward for your help Thank You Gautam ...

Is there any good best practices for exception handling in rails?

I'm currently on Rails 2.3.5 and I'm trying rescue_from exceptions as neat as possible in my Application. My ApplicationController rescues look like this now: rescue_from Acl9::AccessDenied, :with => :access_denied rescue_from Exceptions::NotPartOfGroup, :with => :not_part_of_group rescue_from Exceptions::SomethingWentWrong, :wit...

:with clause preventing action from getting executed in link_to_remote call

I'm experiencing problems with the :with clause in the following code. -counter.times do |c| -elem = @tags[c] #{elem.name}#{link_to_remote image_tag('x.png'), :url => {:controller => 'questions', :action => 'remove_tag_from_cart'}, :with => "'tag_remove=' + #{elem}"} If I take out the :with clause, then remove_tag_from_cart gets e...

how to get record created today by rails activerecord?

How to write the :condition statement if I would like to get all the record which are created today? ...

What's the significance of named scope in Rails?

Before going for details. Question 1:-- What's the meaning of scope here (ie named *scope)?* what's the benefits of using named scope? Now:- from Agile Development with Rails book:-- class Order < ActiveRecord::Base named_scope :last_n_days, lambda { |days| {:conditions => ['updated < ?' , days] } } named_scope :checks, :con...

Styles in Paperclip only if it's an image [rails]

I'm using paperclip to upload all sorts of files (text documents, binaries, images). I'd like to put this in my model: has_attached_file :attachment, :styles => { :medium => "300x300>", :thumb => "100x100>" } but it has to perform the styles only if it's an image. I tried adding if :attachment_content_type =~ /^image/ but it didn...

How to send audio data from Java Applet to Rails controller

Hi, I have to send the audio data in byte array obtain by recording from java applet at the client side to rails server at the controller in order to save. So, what encoding parameters at the applet side be used and in what form the audio data be converted like String or byte array so that rails correctly recieve data and then I can s...

Rails 3 routing - what's best practice?

Hi guys, I'm trying out Rails, and I've stumbled across an issue with my routing. I have a controller named "Account" (singular), which should handle various settings for the currently logged in user. class AccountController < ApplicationController def index end def settings end def email_settings end end H...

RAILS : What is cached when using config.cache_classes = true

Hi, I was just wondering and didn't find explicit response on what in the model class (ActiveRecord) is cached when setting config.cache_classes to true ? Could someone tell me or point me to the doc I didn't found ? Thanks ...

How to add video chat capability to my rails application?

I've been googling about how to accomplish oneline chat for rails application and I've implemented a text chat version using Juggernaut. But for video chat, I only find flash&red5 might be a solution for me, but it's flash and java, which I'm relatively not good at. Is there a better solution? ...

Suggestions for opening the Rails toolbox to design a challenge game?

How would you suggest designing a challenge system as part of a food-eating game so that it's automated as possible? All RoR tools, design patterns and logic are at your disposal (e.g., admin consoles, crontab, arch, etc.). Prize goes to whoever can suggest the simplest and most-automated design! Here are the requirements: User has ma...

Skipping before Create on particular controller alone in rails

Hi Friends, How to skip before_create on particular controller alone in rails example class User < ActiveRecord::Base before_create :validate_email def validate_email ---- end end I want this to be skipped on this controller alone, class FriendsController < ApplicationController ...

rails: I18n locale-yaml-files aren't found

Hi, I'm using I18n in my rails app and all translation files are done. But there is one issue, rails doesn't find the translation files in the locales directory. I made the initializer and so on just like described on the I18n API documentation from the rails guides. Any ideas? Yours, Joern. ...

Fetching Controller Name on Model in rails

Hi, How to fetch the controller name on model in Rails? ...

Paperclip not running tasks but not showing errors

This is strange. I just did a deploy to a cluster server, and since then, pictures have not been processing. Reading the logs, I usually do not get an error at all, but they never finish. However, on one particular image, I found this little bit at least, but this might not explain everything.. Any ideas? Processing PhotosController#edi...

adding class methods to ActiveRecord::Base

I have created an instance method which is also a callback (if that makes sense) which does some stuff thats irrelevant. I would love to be able to just call: class Model < ActiveRecord::Base fix_camelcase_columns end Instead at the moment I have this: def after_find self.class.columns.each do |column| self.instance_eval("d...

Rails 3.0 console won't run

bash-3.2# rails console /opt/local/lib/ruby1.9/1.9.1/irb/completion.rb:9:in `require': dlopen(/opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle, 9): Library not loaded: /opt/local/lib/libncurses.5.dylib (LoadError) Referenced from: /opt/local/lib/ruby1.9/1.9.1/i386-darwin10/readline.bundle Reason: no suitable image found. Di...

How does 37signals job preview functionality work?

Hi all, I'm interested in getting preview functionality working similar to how the 37signals job site does: http://jobs.37signals.com. Below are some screen shots of how it works. Step 1. Create your ad http://cl.ly/dfc4761b015c7f43c8ab (URL /jobs/new) Step 2. Preview your ad http://cl.ly/9c4b4041cfea83d8569e (URL /jobs/new/preview) S...

Moving rails javascript to public while keeping ruby code?

Hi guys, I have a project to move some JS code outside of rails into the public direcotry, but some of it has ruby code embedded, and depends on the values of the variables from the controllers to set some of its code. How can I move it out of the view and still maintain the same structure, or do I need to just rewrite the JS from scrat...