ruby-on-rails

How to fix "dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib"?

I've upgraded to Rails 2.2.2 and installed the MySQL 2.7 gem and am seeing this error when I try to run a migration or start the server: dlopen(/Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysql.bundle, 9): Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib Referenced from: /Library/Ruby/Gems/1.8/gems/mysql-2.7/lib/mysq...

Why doesn't this associated create call work?

I've got a User model that has many Items. A Rating belongs to a User and an Item. In the DB, I have set ratings.user_id to be not NULL. when I am creating an Item, I would like to do this: def create current_user.items.create(params[:item]).ratings.create(params[:rating] redirect_to items_path end However, this balks wi...

Anything wrong with running PHP and Ruby on the same Apache server?

We are trying to figure out the best way to distribute our applications among our available servers, which are few in number. Assuming adequate RAM and CPU power, is there any reason we shouldn't run mod_php and mod_rails (Passenger) within the same Apache server? Would they clash or conflict somehow? ...

Ruby Ecosystem (rake, capistrano, mongrel, etc.?) basics

So I am diving into Ruby (and Rails) and back-end web development in general, and it seems to me there is a huge ecosystem of Ruby projects that seem to be totally essential. I am thinking of projects like Rake, Rack, Mongrel, Gems, Capistrano specifically. Besides these apps' own documentation on their respective project websites, can...

Why is this Rails controller test failing?

I'm trying to understand why this test is failing. (I'm kind of new to testing.) I'm using the built-in Rails testing framework with the addition of the Shoulda gem. The test: require 'shoulda' context "on GET to :new" do setup do get(:new) end should_render_template :new should_not_set_the_flash end Fails: 1) Failur...

Rails - Flow control question, is there a better way?

I am trying to lock-down a few controllers based on role and the 'posts' controller by whether or not they ANY permissions assigned. This appears to be working, but I'm wondering if there is a clean way to handle this. This is what I have in the application controller, which I'm calling as a before filter... if controller_name == 'users...

Routes in Ruby On Rails

I used scaffold to create a model and controller. It worked well. Then I started editing/removing some of the controller actions. So I made participations/new > participations/signup. This does not work, it says "Unkown action" but it does say it has the action signup. Funny thing is if I go to Participations/signup using a capital P. T...

Bottleneck of web applications?

This question pertains to Ruby on Rails and PHP. When looking for a VPS host for a web application (haven't decided which of the 2 languages to write it in yet), what should I take into consideration more? Memory or CPU? I know that you need a fair balance of both, but which wall will I run into first? I'm sure it depends on the type o...

Error when creating associated objects in Rails

I've got a create action that is attempting to create a Rating and a Programme in one go: def create @rating = current_user.ratings.create(params[:rating]) @rating.create_programme(params[:programme]) redirect_to ratings_path end In this code, a rating belongs to both a user and a programme and a user has_many :rat...

Can RoR deal with char(1) fields as "boolean" fields?

I am looking at using Ruby on Rails for a storefront that has to make use of existing data, but I can create my own database schema if I need to. A lot of the fields in the existing data are char(1) emulating a boolean field (i.e. Y/N) for, I believe, cross-platform portability. Since the data is prone to change, I don't want to have t...

How to manage table without id in Rails?

I have two models: Person and Relation. The second one stores information about relations between two people. It has parent_id and child_id fields and doesn`t have id field. I connected it with has_many :through and it works. But: Relation.find(:all) returns empty array even if there are some relations in the table (becouse there is n...

Removing accents/diacritics from string while preserving other special chars (tried mb_chars.normalize and iconv)

Hi, There is a very similar question already. One of the solutions uses code like this one: string.mb_chars.normalize(:kd).gsub(/[^x00-\x7F]/n, '').to_s Which works wonders, until you notice it also removes spaces, dots, dashes, and who knows what else. I'm not really sure how the first code works, but could it be made to strip only...

rails if object.nil? then magic '' in views?

This is one of those things, that maybe so simple I'll never find it because everyone else already knows it. I've got objects I have to check for nil in my views so I don't dereference a nil: <%= if tax_payment.user; tax_payment.user.name; end %> Or I could do this variant: <%= tax_payment.user ? tax_payment.user.name : '' %> So t...

Kdevelop as a Rails IDE

I would like to use Kdevelep as a Ruby on Rails IDE as I'm using Linux. How do I set up Kdevelop to enable this? ...

Why are my fixture objects not available in my Rails Test::Unit test?

According to this Rails guide, if you create a fixture, it becomes available in your test class. I have this fixture in users.yml: <% stan = User.new stan.username = 'stan' stan.set_hashed_password('mysterio') stan.email = 'stan@abc.com' %> stan: username: <%= stan.username %> hashed_password: <%= stan.hashed_password %> ...

How do you send a request with the "DELETE" HTTP verb?

I'd like to create a link in a view within a Rails application that does this... DELETE /sessions How would I do that. Added complication: The "session" resource has no model because it represents a user login session. CREATE means the user logs in, DESTROY means logs out. That's why there's no ID param in the URI. I'm trying to i...

What's the correct way to log a user out of a Rails application?

I'd like to provide a "log out" function in a Rails app. Should I do... session.delete or reset_session From reading the docs, both look like they could work. Does it matter? Or should I use something else? ...

What does !! mean in ruby?

Just wondering what '!!' is in ruby. thanks! ...

Can we use RubyOnRails for Banking and financial transactions domain.

Can we use RubyOnRails framework to develop websites for financial transactions & banking transcations. Is RubyonRails a DSL for banking Domains. Some days on DSL, i believe most of the facts of Banking system are static and they may not need any subsequent alterations.. simultaneously. So defining a DSL, one way process must work. ...

Populating a Rails class in the migration

I'm trying to create a migration for a simple table that is just used as an enum. So I want to populate the table immediately with its values. I tried the following: class CreateUserTypes < ActiveRecord::Migration def self.up create_table :user_types do |t| t.column :type, :string t.timestamps end end def self....