ruby-on-rails

How to stub an users_controller | authlogic, rspec2, rails3, factory_girl

My users_controller.rb # GET /users/1/edit def edit @user = current_user #@user = User.find(params[:id]) end my sweet looking users_controller_spec.rb ( notice all my commented out attempts ) describe "Authenticated examples" do before(:each) do activate_authlogic UserSession.create Factory.build(:valid_user) end des...

rails multiple form actions with ajax...

I have a basic Rails form like so: <%= form_for @person do |f| %> <%= f.label :first_name %>: <%= f.text_field :first_name %><br /> <%= f.label :last_name %>: <%= f.text_field :last_name %><br /> <%= f.submit %> <% end %> How could I optionally send the form information to another an entirely different controll...

Ruby on Rails: How to pass parameters from view to controller with link_to without parameters showing up in URL

I am currently using a link_to helper in View to pass parameters like title , author ,image_url and isbn back to controller <%= link_to 'Sell this item',new_item_path(:title => title, :author => authors, :image_url=>image, :image_url_s=>image_s, :isbn=>isbn, :isbn13=>isbn13 ) %> Controller will then assign the parameters to an object ...

Why is ruby not so popular in linux scripts comparing to python

Can you please explain me, why despite of great ruby popularity for web applications thanks to rails framework it is still not used or very rarely used by linux users to create system apps/scripts. We can compare it to python, witch not only has django and others for web applications, but is also commonly used as scripting language in li...

Rake trouble finding MySQL after uninstalling Rails 3.0.0

So I thought I had fixed the problem posted in this question and I uninstalled Rails 3.0.0 with sudo gem uninstall rails -v 3.0.0, but then I had troubles with other things. I took rogerdpack's advice to a different level and uninstalled all of my ruby gems and mysql, then reinstalled them. Now I get the following: Icarus:temporary atg...

authlogic perishable token can't be null

I get this erorr eerytime I try to create a user from the console. I used to be able to do this, but ever since I turned off PT maintenance, this could have become a problem. Thing is I do supply a value for the PT using Authlogic::Random.friendly_token, but it seems this value never shows up in the SQL statement. What do I need to do ...

Validation of Facebook Badge in Rails form

I would like users of my Rails application to be able to submit their Facebook Badge as input in a form, but I absolutely want to to verify that what they provide is a valid Badge, not something that may compromise the security of my system (Javascript ...). Is there a good way to validate a form field that contains a Facebook Badge? ...

Rails 3 run_callbacks method

Hey guys, I'm playing around with the new Rails 3 API and I have a question regarding the new method run_callbacks(kind, *args, &block) In the following code: class User < ActiveRecord::Base before_save :say_hi after_save :say_bye private def say_hi; puts "hi"; end def say_bye; puts "bye"; end end I can explicit cal...

Creating Join Tables for has_many & belongs_to Associations

Hello, Rails 3 newbie here... I'm working to create a devise auth system that like (yammer) has instances where users belong. I have two tables Users (email, password...) belongs_to :instance Instance (domain name, active....) has_many :users I added the belongs_to and has_many to the models but the schema hasn't been updated to a...

PDFKit middleware problem on Rails 2.3.8

I have installed PDFKit and wkhtmltopdf on my Ubuntu 8.04 server. I am trying to use PDFKit as middleware in my Rails 2.3.8 app and have added the following lines to environment.rb (as directed on the jdpace pdfkit page): require 'pdfkit' config.middleware.use PDFKit::Middleware My Mongrel seems to start up but as soon as I request a p...

Rails 3, I added a Table, then added a Column, now I want to add an Index

In Rails 3, I created a table with a migration, then added a column with a migration which creates a has_many, belongs_to relationship.... I then ran rake db:migrate I'd like to now add an Index because I forgot to add it before I can migrate. can I add that to one of the existing migration files (the create table one) or do I need to...

Speeding up the rails 3 development server

Now that Rails 3 is out, my favorite dev-mode plugin (rails-dev-boost) is broken. I'm working on a large application (>100 models and controllers) and loading them all every request takes more than ten seconds. I could turn config.cache_classes on, but then I might as well run in production mode since I have to restart the server every c...

Rails 3, CanCan to limit all query results throughout the app based on User's InstanceID

Hello, I have two tables Users (name, email, password, instance_id, etc...) example: james bond, [email protected], 1 Instance (id, domain) example: 1, abc.com Through out the application I want to make sure James Bond only sees data that is assigned to his instance = 1 So if I have a books table with (name, desc, instance_id), he only ...

How to KISS and smart this method

I have an action in my RoR application, and it calls a different script depending on the user running it. def index @user = User.find(session[:user_id], :include => [ :balances, :links, :comments ]) render :file => "#{RAILS_ROOT}/app/views/user/index_#{@user.class.to_s.downcase}.html.erb" end How to make the call to render a m...

Deploying a Rails app: Uninitialized constant Haml::Filters::Markdown

I am in the process of deploying a Rails application (that works fine in development) to a new production server running Apache and Passenger. When I navigate to the main page, I get the following in my production.log (along with a 500 Internal Server Error from Apache): ActionView::TemplateError (uninitialized constant Haml::Filters::M...

after_find callback broken after upgrade to rails3

Grettings! In an app that was working flawlessly in Rails 2.3.8 i have the following class method: def self.encode(*attr_names) encoder = Encoder.new(attr_names) before_save encoder after_save encoder after_find encoder define_method(:after_find) { } # defining here, since there's only alias in the Encoder class i...

Mongodb crashed! Where has my data gone?

Please help! Mongodb crashed on my server. When I started the mongod backup I have no data in database! Looking at the data/db/ directory I have the following 5 files: mongo.lock production-mongodb 4k production-mongodb.0 64m production-mongodb.1 128m production-mongodb.ns 16m I think mongo has somehow started a new...

how to require active record working outside of rails

i need to require active record, but I am working outside of rails (here is why: Simple Ruby Input Validation Library). do I need to require the entire rails gem, or can i be DRYer? ...

Does anyone have a Ruby on Rails application with 500+ tables?

I am working on developing a large SAAS application and I had planned to do so in Ruby On Rails. However, most of the threads that I have read here and there on the Net seem to indicate that 100 tables is considered to be a large RoR application. I would be very interested to hear about scalability/size issues that anyone has seen and ...

How do I create a blacklist/whitelist for finding Rails model records?

I want to create a model, "Whitelist" to build a list of users that I do not want displayed in my main model, "User". Example Controller def index @users = User.find(:all) #These are to be filtered behind the scenes in the model end Example Model class User ActiveRecord::Base has_many :whitelist def self.find #Add somethi...