ruby-on-rails

Is RubyAMF production ready?

Am considering using it for a project. It keeps getting recommended to me. I am wondering if anyone has had any success and can comment? ...

Optimize Rails eager loading query for find all

In a Rails 2.3.5 application I've got something like the following models: class Foo < ActiveRecord::Base has_many :bars end class Bar < ActiveRecord::Base belongs_to :foo end And when I'm calling Foo.all(:include => :bars) I see the following queries in console: SELECT * FROM "foos" SELECT "bars".* FROM "bars" WHERE ("bars...

Ruby/Ruby on Rails ampersand colon shortcut

In Ruby (actually only in Rails, apparently), I know that if I do: some_objects.each(&:foo) It's the same as some_objects.each { |obj| obj.foo } That is -- &foo creates the block { |obj| obj.foo }, turns it into a Proc, and passes it to each. Why does this work? Is it just a Ruby special case, or is there reason why this works as...

Rails: How to send emails to a recipient containing umlauts?

I'ld like to send an email with the following setup def registration_confirmation(user) recipients user.username + "<" + user.email + ">" from "Netzwerk Muensterland<[email protected]>" subject "Vielen Dank für Ihre Registrierung" body :user => user content_type "text/html" end The su...

How to avoid loading my models in a rails Migration

I have a rails project that uses an old versions of the FlexImage plug-in to handle images. In the old version that image data was stored in a column called "data", in the new version that column must be named "image_file_data". I wrote a migration to rename the column, but when I try to run the migration, my guess is that rails tries...

Accessing models from Flex through WebORB on Ruby on Rails

Hi, I'm using the RiaForge Plugin for Flash Builder 4 and WebORB for accessing data from my Rails application. In Rails I defined the dependencies of my models by using has_many, belongs_to... I've got some models, for example the User model and the Picture model (user has many pictures, picture belongs to user) Creating services in A...

How can I make the "edit" action the default action?

I have a RESTful resource map.resources :books and I want to make the edit action the default one, in other words: /books/1 # edit action /books/1/show # show action Is this possible? ...

testing (rspec) nested model partials in rails 2.3+

With the 2.3.x+ rails feature of nested models, I think I need to have access to a form builder instance to properly spec partials for rendering the nested models. Pulling from the complex-forms-examples: For example, here is an enclosing form that creates and passes the form builder to the nested model rendering view: <div class="chil...

Encoding::CompatibilityError in rails

<%= link_to '注销', :controller => :user, :action => :logout %> this raises Encoding::Compatibility exception, and when i try <%= link_to '注销'.force_encoding('utf-8'), :controller => :user, :action => :logout %> this didn't help, either. but this works <a href="<%= url_for :controller => :user, :action => :logout>">注销</a> why ??? i...

Rails, select_tag, :onchange => not ajax request

I have a select tag with :onchange which updates the page with relevant data, however, I don't want to do it with Ajax because it is messing up my navigation structure. I want to use select_tag and when they its is changed it sends a regular HTML request which refreshes the entire page. How can I do this. ...

Rails 2.3.5: ActiveSupport CoreExtensions install trouble

I get the following error "uninitialized constant ActiveSupport::CoreExtensions" when trying to ActiveSupport::CoreExtensions::Time::Conversions::DATE_FORMATS.merge!( ?> :my_date => lambda { |time| time.strftime("%a, %b #{time.day.ordinalize}") All I'm trying to do is format dates in rails, but the bloody thing can't find Activesuppo...

Image_tag doesn't work after migration rails 2.0.2 to 2.3.5

Hi guys, I want to upgrade my rails application 2.0.2 to 2.3.5. After many problem with mysql, I have another big problem with my application. Here is the problem: Processing UserController#profil (for 127.0.0.1 at 2009-12-26 11:47:13) [GET] Rendering template within layouts/admin Rendering user/profil ActionView::TemplateError (unde...

How to validate user input in RoR?

I know that the RoR can do the validation in the models. But I want to confirm the user's password in the views. I means, it show two textfield for user to type password twice to ensure the user type the password correct, but in the database I only store one value. How can I handle it in the RoR? ...

Suggested username plugin for Ruby on Rails?

Does anyone know of a "suggested username" plugin for Rails? I want something that will check if a username is available as a user types and display suggested usernames if unavailable. I know this would be easy to implement, just wondering if anyone has seen something out of the box. Thanks! ...

which gem to use for uploading photos for making albums

hi i've been googling around and cant really find the most obvius answer for which gem would be best to use. if i would be using it for lets say creating albums, avatars and thumbnails. that means also allowing multiple pictures upload, ofcourse resizing them and maybe adding them borders. i've come across RMagick, MiniMagick, PaperCli...

find_by_field not working properly in ActiveRecord

I have a navigation system that provides a permalink for any link setup. When i run the line through script/console this is what it returns: >> Navigation.find_by_permalink("gems") => #<Navigation id: 10, text: "Gems", parent: nil, destination_controller: "pages", destination_action: "show", destination_id: "1", permalink: "gems", crea...

Upgraded to Rails 2.3.5 and Eager loading stops working?

I just upgraded to rails 2.3.5 and a find statement with some eager loading that was working perfectly before, suddenly stopped working. Advertisement.find :all, :include => [{:user => :contact}, {:apartment => {:building => :address}}], :conditions => [query_info[1]], :order => query_info[0] This is the error I get Mysql::Error: Unk...

What is Scaling?

I always get this argument against RoR that it dont scale but I never get any appropriate answer wtf it really means? So here is novice asking, what the hell is this " scaling " and how you measure it? ...

Rails model generator - from existing database

Hello, Is there any working automatic model generator for creating a model from existing database? Something like symfony's task symfony doctrine:build-model. I found just Dr Nic’s magic model generator but it doesn't work with rails 2.3+. Please do not recommend Dr Nic's magic models. That's not what I want. I don't believe that ther...

How to create password protected RSS feed in rails

Creating RSS feed in rails is easy. I need a simple way to password protect the RSS feed. I am thinking http basic authentication. I googled but could not find any article about creating password protected RSS. ...