ruby-on-rails

How to avoid OCIError in rails application?

OCIError (ORA-12541: TNS:no listener): oci8.c:270:in oci8lib.so /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapter-1.2.4/lib/active_record/connection_adapters/oracle_enhanced_oci_connection.rb:223:in `new' /usr/local/ruby-1.8.7-p248/lib/ruby/gems/1.8/gems/activerecord-oracle_enhanced-adapte...

Passing user_id, site_id, and question_id to same table on create...

I can't seem to figure out how to do this. I am trying to pass four different variables to a single table. To be more specific I am trying to create a "like" in a likes table that also captures the site_id (like an answer), user_id, and the question_id. Here is the set up. class Like < ActiveRecord::Base belongs_to :site belongs_to ...

Removing email activation from restful_authentication plugin

I have a Rails app handling authentication with the restful_authentication plugin. I'm experiencing problems with the email activation feature and before I deal with that I would like to just allow my users to register without having to go through the email activation process. How do I disable the email activation feature. Rails 2.2.3...

Rails 2.3.5: flash[:notice] disappears after redirect_to call

Here I've got two controller methods: def invite if request.post? begin email = AccountMailer.create_invite(@user,url) AccountMailer.deliver(email) flash[:notice] = "Invitation email sent to #{@user.email}" rescue #mail delivery failed flash[:error] = "Failed to deliver invitati...

ActiveMerchant Integration usage example?

Where can I find a complete example of ActiveMerchant Integrations usage? I can see tons of examples of Gateways' usage, but couldn't see how an Integration should be used (e.g. what do you do in the return_url and cancel_return_url controller actions?) ...

DataMapper: using auto_migrate! with many-to-many dependencies?

Hi, I'm trying to migrate my app from MySql to Postgresql, using Rails3-pre and the latest DataMapper. I have several models which are related through many-to-many relationships using :through => Resource, which means that DataMapper creates a join table with foreign keys for both models. I can't auto_migrate! these changes, because I...

rails log rotation behaves weird (rails version 2.3.5)

I'm trying to setup log rotation in rails. I have put this in my environment/development.rb: config.logger = Logger.new("#{RAILS_ROOT}/log/#{ENV['RAILS_ENV']}.log", 1, 5*1048576) 2 files are created :-) but it looks like rails is writing to them randomly and at the same time as well. This creates messy log files :-( what am I missing? ...

Rails Model multiple column uniqueness

I am making a Viewer model with belongs_to :users belongs_to :orders that joins the models Users and Orders with a :has_many :through => :viewers. And the Viewer model has the attributes of user_id and order_id. How would I set it up so that new viewers are only accepted if both user_id and order_id are unique in the same row? I re...

no route matches error at file

Hi @all, i'm having a no route matches error after a render :partial <% unless @user.uploads.empty? %> <% @user.uploads.each do |u| %> <tr> <td><%= link_to u.filename, u.filename %></td> it gives me the right filename like http://localhost:3000/DSC00082.JPG. i haven't added anything to my routes. for being new to rails, please excu...

Rails - why would a model inside RAILS_ROOT/lib not be available in production mode?

Hi - I have a class located inside RAILS_ROOT/lib folder, which I use in one of my helpers, and it works great in development. When I switch to production, the application throws a NameError (uninitialized constant SomeHelper::SomeClass), and I have to load it manually in the helper: load "#{Rails.root}/lib/some_class.rb" module So...

Rails: Updating an object referenced via different association paths

I have a User object, that is related to a Post object via two different association paths: Post --(has_many)--> comments --(belongs to)--> writer (of type User) Post --(belongs to)--> writer (of type User) Say the following hold: user1.name == "Bill" post1.comments[1].writer == user1 post1.writer == user1 Now when I retrieve the ...

Warning while installing the rails plugin

Hi...I am getting the following warning while installing any plugin in my rails application. /usr/local/lib/ruby/gems/1.9.1/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/agnostics.rb:7: warning: Insecure world writable dir /usr/local/bin in PATH, mode 040777 Can someone please tell me how to solve this problem? Thanks ...

Build a gem with native extension (Gem::Installer::ExtensionBuildError)

I have the following configuration: uname -a : Linux 2.6.24.2 i686 GNU/Linux (Ubuntu) ruby -v : ruby 1.9.0 (2007-12-25 revision 14709) [i486-linux] rails -v : Rails 3.0.0.beta3 gem -v : 1.3.5 rake --version : rake, version 0.8.7 make -v : GNU Make 3.81 gem env : RUBYGEMS VERSION: 1.3.5 RUBY VERSION: 1.9.0 (2007-12-25 patchlevel 0) [i4...

Setting up Ruby on Rails beginner netbeans

WOW. Setting up is complicated, can anyone recommend a link or provide me with some advice. I have two options, a Linux Hosting server with it pre-installed or through NetBeans. Sorry for the generic question. ...

.NET to Rails (Want to move from .net to rails)

I have been a .NET developer for the last 7 years. Now I want to move to a Ruby on Rails stack. Also, I don't have any experience with Linux. Anybody else who made the same move? Any suggestions? Good books? I am having some idea about ASP.NET MVC ...

Expire headers in Rails

Hi, I started using YSlow and I noticed that I haven`t got expire headers on my static files. So I did a little research what is that and how to add it and tried to turn it on from the .htaccess file. But the problem is that when I put the code in the file apache returns me a 500 error. And I started thinking that the problem is from Rai...

Rails: first time works, then doesnt.

I run the server, it works, i refresh the page with no edit and i get: undefined method `new' for Smodules::Grid:Module. why?? i dont get it! so nervous ...

How can I use ExceptionNotifier in my models?

I have a transaction in one of my model. When something go wrong, I want to be notified. If it would be transaction in controller, I would simply do: begin (my transaction...) rescue => exception ExceptionNotifier.deliver_exception_notification(exception, self, request, data) end But I want to do similar thing in my model, passin...

how to return clean javascript from a rails3 custom view helper?

Using Rails 3: In my update.js.erb file I found I was repeating a lot of stuff. So I tried to put it all into a helper. But I'm having trouble getting the helper to give back clean javascript. It puts in \&quot; everywhere instead of " Here's what I started with: <% if @list.show_today %> $("#show_today_check_<%= @list.id %>").rem...

Evaluation of a Ruby variable in a jQuery statement passed to :onclick in Rails

I'm iterating over records and want to create the toggle-options for records but I can't replace the div-id with the records: <% for bill in @bills %> <% tmp = "test"%> <%= link_to '&raquo now','#', :onclick => '$("#{tmp}").toggle();' %> Instead of getting: <a href="#" onclick="$(&quot;#test&quot;);">&raquo now</a> I'm getting: <a...