ruby-on-rails

dynamically set named_scope based on current_user

Hey all, I keep getting the following error: You have a nil object when you didn't expect it! You might have expected an instance of Array. The error occurred while evaluating nil.size Based on the current user, when they navigate to a page, I want to limit them to what they can see based on their site. Problem is there is no associat...

Can't install ruby 1.9.1 on MacOSX 10.6

Hi all, I can't seem to be get Ruby installed on my Mac. These are the steps I've taken so far: Downloaded the package from Ruby's site (http://www.ruby-lang.org/en/downloads/) Unpacked it running { tar xzvf ruby-1.9.1-p376.tar.gz } Went into the new ruby folder, and configured using {./configure} This is where the error happens. ...

Ruby on Rails: passing parameters from other controllers to a model

I have in a users_controller: @user = User.new(params[:user]) Passing parameters to a User model which works fine. I need to pass some additional parameters labeled "profile" to the user model through the users controller. This didn't work: @user = User.new(params[:user, :profile]) Neither did this: @user = User.new...

I Don't Need a Facebook App, I just want their API (in Ruby)...

Can I use Facebooker without having to create a whole Facebook App in their Developer section? I don't need to create a Facebook App with Facebooker, I just want to be able to create events and posts on Facebook with my own custom admin panel on my site. Facebooker seems to have everything built already, so I wouldn't want to use just ...

validate presence of not working in form_for tag

This is my first time doing validation on a rails application. I saw many tutorials which made it seem easy. I don't know why I cant get it to work. Below is my setup. Controller Admin (action = login) def login session[:user_id] = nil if request.post? @user = User.authenticate(params[:userId], params[:password]) ...

Ruby on Rails POST parameters on redirect_to

I have to make a call to a different url in one of my controllers on my site. The problem is that with all the parameters the other site requires I'm overflowing the url. Is there anyway to call another url from the controller and send all of the parameters using a POST? I'm not expecting a response from the other site. Also, I think...

flickr photos from flickr_fu come back with a different id everytime

@photos = flickr.photosets.get_list(:user_id => Flickr_Keys::USER_ID).find_all{|set| set.id== @gallery.flickr_id}[0].get_photos @photos[0].id "4016105430" But everytime i run this piece of code in irb, i get a different id for each request. Whats up with that? Am I supposed to use the 'secret' property as a unique identifier ? ...

Rails truncates hash on save:

I have a rails model with a hashed password field in it (surprise, surprise), which after some manipulation, is 40 characters long. I generate a user in script/console and it appears as follows: #<User id: 1, firstname: "true", lastname: "false", username: "chaines51", hashed_password: "2Gr0GWvPunB3x5jomRTSTZJRIelC2RW103d7f3db"> I the...

Rails ACL plugin that works with devise/warden?

As title, warden is very pluggable, I wonder if there is anything works with warden/devise? ...

heroku db:push showing invalid database url

I am trying to push data to a heroku app by using heroku db:push but it is spitting out this error: root@ubuntu-lappy:~/rails/soft$ heroku db:push Invalid database url any clue regarding this? my taps installation went fine because I was able to push the DB out before. Is there something in particular I should be looking at? ED...

How to silence gem errors after switching to bundler

I recently switched to using bundler and now anytime I run a script under the scripts/ folder in my rails app I get the following warning: config.gem: Unpacked gem environment.rb in vendor/gems has no specification file. Run 'rake gems:refresh_specs' to fix this. config.gem: Unpacked gem environment.rb in vendor/gems not in a versioned ...

sql injection prevention for create method in rails controller

As seen in comment_controller.rb: def create @comment = Comment.new(params[:comment]) @comment.save end Im assuming that this is SQL injection-unsafe. But what is the correct way of doing it?.. All the examples on the net deal with finds. ...

custom attr_reader in rails

Mostly in rails if you write my_obj.attr it looks up attr in the database and reports it back. How do you create a custom def attr method that internally queries the database for attr, modifies it and returns? In other words, what's the missing piece here: # Within a model. Basic attr_reader method, will later modify the body. def attr ...

Ruby on Rails for web applications, Django for webpages?

Days ago I read something like "Ruby on Rails is for web applications, Django is for standard webpages". Is that true? I have to decide in the next weeks if I go with Ruby on Rails or Django for an university project. It will be an email marketing software. What do you advise me to use? ...

Good Ideas for Automating Common CRUD Operations in Rails

Short version: What are some good ways to allow the end user to define "processes" or sequentially executed CRUD operations in a fairly large project, so they can build templates for common processes (like creating 2 tickets for each new event posted automatically)? Something like Cucumber, but for CRUD operations..., or even Selenium? ...

Protecting IP from Overseas Contractor Theft

Hello SO, The nature of our business often has 2-3 remote developers working on a single project (mostly Rails), and each one currently has carte blanche access to source so they can checkout, run, and develop locally. The problem is any one of them could ship the whole base out the back door. Overseas legal action seems futile. I'm ...

Who Creates Custom ActionMailer Layouts in Rails, You or the Client?

When projects get large, I imagine you might start having 100s of mailer templates: user_signup_confirmation.html.erb user_signup_failure.html.erb user_account_activation.html.erb user_account_cancelation.html.erb ... What is your workflow for handling this? Do you have them email you what they want and then you mold it into a metho...

Rails: How do I write tests for a ruby module?

I would like to know how to write unit tests for a module that is mixed into a couple of classes but don't quite know how to go about it: Do I test the instance methods by writing tests in one of the test files for a class that includes them (doesn't seem right) or can you somehow keep the tests for the included methods in a separate f...

Rails - Using another app's SOAP interface

I've got a pure, working, Rails application. I now need it to start communicating with another application (sympa). This application exposes that exposes a SOAP interface, so it makes sense that I try to use it (the command line interface is incomplete). Which steps should I follow? What gems/plugins should I use? Does anyone have wo...

Will upgrading gems break old Rails applications?

I have bunch of Rails apps running on Rails 1.x. I need to upgrade the gems so the question is, will these old apps still work after I upgrade gems? Thank you. ...