ruby-on-rails

Dragonfly question

Hello! I tried switching from gem rails 3.0.0.rc to rails 3.0.0 in my Gemfile recently and when doing so I got a problem with Dragonfly when starting the server. The error message says: /Library/Ruby/Gems/1.8/gems/aws-s3-0.6.2/lib/aws/s3/extensions.rb:206:in `const_missing': uninitialized constant Dragonfly::Config::HerokuRailsImages (...

Rspec testing templates being rendered

Im trying to test a condition where on successful signup a Success Template is rendered by the following controller code def create @user = User.new(params[:user]) if @user.save render :template => "success" else flash[:notice] = "Oops Somethings not quite right! :(" render :action => "new" end end ...

Cancan not showing authorized view elements

Hi there, I'm trying to get some basic authentication/authorization with devise/cancan with Rails. Rather than using roles like Ryan B's screencast and other examples around I'm trying to do something basic: 1 - A user can log in 2 - A user can only edit/destroy their own articles (no roles, you're either logged in and can create new ...

Storage of different data formats in Rails dynamically defined by admin

I'm facing a problem where I cannot permanently decide which columns one of my models will have. A use case will be this: An admin creates a new dataset, he wants users to answer. In the dataset the admin defines several data points of different format and units. I could imagine the classes to look similar to this: class Dataset < ...

Devise and swfupload authorization

i'm trying to verify in my controller whether user has sufficient rights to upload files or not. swfupload does a POST request with (according to documentation) cookie values passed directly in POST request. this makes before_filter :authenticate_user! unusable, user is not authorized correctly. as far as I know from devise docs, there ...

Ruby vs Python when building high performance webapp

Hello there I'm building a high performance webapp, it needs a) good team scaling i.e. new team member needs to be able to quickly get started b) good app scaling, so the request load can grow I was thinking between RoR and ruby + postgres vs Python and some framework; I would like to avoid windows server administration and also I had...

Command - R like functionality in MacVim

I'm on a Mac and when I am in TextMate editing a ruby file I can simply hit Command-R to execute the file and see the results in a new window. Is there something similar to this using MacVim? It's really important that I be able to open up a NEW window. Reason is because in the current window I might have more than one full page of info...

Declarative Authorization - Catch "Authorization::NotAuthorized" Exception

I'm currently using Declarative Authorization on my application, and trying to catch Exceptions from type Authorization::NotAuthorized. I have an Entity that has a category. Depending on the role a user can create a new category when creating this entity. At my :before_validation callback I assign the category and want to be able to cat...

rails gsub question

Hi, How can i replace " " and "_" with "-" in my controller when creating a new post? I have the following form fields: title url content I want to execute the gsub on the url field. Thanks... ...

A different label for each iteration

Hi, in the following code, I want to assign a different label to the text field for each iteration. <%= f.field_for :skills do |s| %> <li> <label>Skills</label> <%= s.text_field :name %> </li> <% end %> How can I do that? Here is my controller code, where I create three different skill objects: def edit 3.tim...

Sudden problems with using dispatch.fcgi with an old rails application

I'm maintaining an old rails application that was working just fine until recently. I believe it uses fcgi and lighttpd on Debian for deployment. Normally when release a new version, I restart lighttpd and everything is fine. Today for the first time I got the following error message when trying to restart I don't know what any of this...

activerecord sum returns a string??

This seems very strange to me, an active record sum returns a string, not a number basket_items.sum("price") This seems to make it work, but i thought i may have missed something, as this seems like very strange behaviour. basket_items.sum("price").to_i ...

Cannot Install Ruby Gems 1.3.7 on Mac OSX 10.6.4

I am following the instructions at http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard to install ruby 1.9.2 and rubygems 1.3.7 Everything goes smoothly until I get to the "Compile and Install RubyGems" part and enter the command line: sudo /usr/local/bin/ruby setup.rb This continually returns the followin...

Rails not working with Safari

Hi, I'm trying to learn some basics of Ruby on Rails and encountered a problem : my Rails project seems to work fine with Firefox but nothing is shown with Safari? I also tried this with a new project : rails emptytest cd emptytest script/server Producing output: => Booting Mongrel => Rails 2.3.5 application starting on http://0....

Where do the Rails 3 environmental variables belong?

Hi I'm relatively new to Ruby on Rails 3 and hope to integrate Ambethia's Recaptcha plugin into my app. In following what looks like Rails 2 documentation, it's asked to place the following into environment.rb ENV['RECAPTCHA_PUBLIC_KEY'] = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' ENV['RECAPTCHA_PRIVATE_KEY'] = '6Lc6BAAAAAAAAKN3DRm6...

Rails: Create association if none is found to avoid nil errors

I have an application where my users can have a set of preferences. Both are stored as ActiveRecord-models as follows: class User < AR::Base has_one :preference_set end class PreferenceSet < AR::Base belongs_to :user end I can now access the preferences of a user: @u = User.first @u.preference_set => #<PreferenceSet...> @u.pre...

Converting non-Latin characters (bulgarian) to ASCII with Stringex

It looks like converting Cyrillic is specifically suited for the Russian language, however in a Bulgarian context it sounds funny. For example: "голем проблем" is converted to "goliem-probliem" :) Can I change how some of the characters are converted? ...

Devise named_routes problem

I'm having a problem with some devise routes. The session named routes have the actions in the rong place. It should be 'new_admin_session' and 'destroy_admin_session', but instead it's 'admin_session_new' and 'admin_session_destroy'. Anyone know what's happening? admin_session_new GET /admin/sign_in(.:format) {:a...

Paypal IPN Acknowledge Failing Only On Live Site (Not In Sandbox)

We're trying to get IPN working with the Paypal gem (Paypal::Notification). Everything works fine in the sandbox, but against the live site paypal returns INVALID every time for acknowledge. Here is the code: def ipn # Create a notify object we must notify = Paypal::Notification.new(request.raw_post) logger.info "ORDER_CREATE:RAW_R...

Help me find out why new and build method doesnt work

Hello, I have problem with my associations. I have n:n relation and everything going good but if i want initialize new object and then save it, it will by save with out associations. For example. Models: class User has_many :users_in_organizations, :class_name => 'UserInOrganization' has_many :organizations,:through => :users_in_o...