ruby-on-rails

fullcalendar with rails - limit results to a range

I've got fullcalendar working with a small rails app (yeah) but it's sluggish because the find in my controller is finding ALL the records before it renders the calendar. I'm using a JSON approach. The field names I'm using are starts_at and ends_at. This (in the index method of the assignments_controller) works: @assignments = Assignme...

Rails cookie being set, session variable in cookie readable, session not readable

When setting session variables using cookie store in Rails 2, I can see the _domain_session variable being set as expected, and it shows up in the cookies in my browser. However, whenever I try to access the request.session hash, it's always empty, except for immediately after setting the session. # In a controller Rails.logger.debu...

Before_save filter not working

I dont understand, nothing could be simpler: class Visit < ActiveRecord::Base def before_save self.visited_on = "test" end end Yet, if I do: a = Visit.first a.user_id = 5 a.save a.visited_on => nil #WTF? I know that filters must return true, but this one is... What could be the issue? ...

Why is my Ruby on Rails RSpec test passing with both @plugin and @plugins?

I'm in Chapter 10 of the Foundation Rails 2 book. We're working with RSpec. We're testing the 'index' action of the 'PluginsController'. Here's the code for the controller: class PluginsController < ApplicationController # GET /plugins # GET /plugins.xml def index @plugins = Plugin.find(:all) ...

rails conditional form/remote_form

I have a form partial that needs to render a remote_form_for or a form_for depending on the value of a local variable passed into it from the caller view. It looks like... <% if ajax %> <% remote_form_for @search, :url => {:action => :search_set, :controller => :searches, :stype => stype} do |f| %> <% else %> <% form_for @searc...

Is there a Ruby on Rails framework like equivalent for .NET development?

Answers like ASP.NET MVC or Entity Framework really aren't acceptable as they address just one aspect of the problem domain. I'm looking for a framework ... a REAL framework that gives me the same features out of the box that Rails does. As such it should include at minimum: MVC for presentation ORM Ability to provide simple configur...

Rails: can't convert ActiveRecord::Associations::BelongsToAssociation into String

This rails project is very bare-bones, just begun, so I haven't done any weird loopholes or patching. The model, to_s replaces school with bar if nil: class Department < ActiveRecord::Base belongs_to :school def to_s "foo" + (school || "bar") end end Says the view: can't convert ActiveRecord::Associations::BelongsToAssocia...

Do you prefer Python/DJango, or Ruby on Rails in creating a web app?

I was recently in a Software Engineering class that involved a semester-long group project. We were given requirements and were asked to build a piece of software to assist in a task. In our case, a Psychology professor wanted something to help her students track their sleep patterns. My group pretty successfully used DJango to create a...

rails form checkbox array/hash value

How can I create a checkbox that stores a hash, so that when I retrieve the value in params array I get a hash. ...

Ruby on Rails worth learning?

Hi, I use PHP+Zend and Java+Wicket and learn Python (so will have Django available). So I want to know if it is worth learning RoR for rapid web-development. Is it much faster building web-apps than with the other approaches or is it neglectable? Or let me rephrase it: What are the facts that make RoR much faster in rapid development...

"getaddrinfo: Name or service not known" while rake db:migrate

# rake db:migrate --trace (in /www/rails_app) ** Invoke db:migrate (first_time) ** Invoke environment (first_time) ** Execute environment ** Execute db:migrate rake aborted! getaddrinfo: Name or service not known /usr/local/lib/ruby/gems/1.9.1/gems/postgres-pr-0.6.3/lib/postgres-pr/connection.rb:165:in `initialize' /usr/local/lib/ruby/ge...

ruby on rails language problem "invalid byte sequence in GBK"

This is definitely a language issue, both of our code and our database contains Chinese characters. **This is my environment: About your application's environment Ruby version 1.9.1 (i386-mingw32) RubyGems version 1.3.5 Rack version 1.0 Rails version 2.3.5 Active Record version 2.3.5 A...

Resize existing images to new style in paperclip & RMagick

I've been using paperclip to upload and auto-resize photos in my Rails app, and I love it. Only problem is about every other month my crazy manager decides he wants a new size to display the photos in. So I add a new style in my Photo model and all is good for new photos, but the pre-existing photos are now a problem. Now that I'm starti...

How to Uninstall A Plugin (Seed Fu) From Rails

Hi, We installed Seed Fu to add in seed data in rails, then noticed that it isn't working right - doing some digging, we realized that Rails 2.3.8 comes with seeding built in, and seed fu might be deprecated. Now we're trying to uninstall seed fu, but are not sure of the right way to do it. We installed seed fu using script/plugin in...

Setting up sendgrid for rails..returning Authorization error

The emails now send from my local, but do not send from my box. I am returned this error. Anyone know what this might be? Net::SMTPAuthenticationError (535 5.7.8 Error: authentication failed: authentication failure ): My environments/production.rb ActionMailer::Base.delivery_method = :smtp ActionMailer::Base.smtp_settings = { :addr...

On Ruby on Rails, how to run ONE functional test when another one is breaking?

let's say you added a controller and action (example: story/index), and want to run a functional test by rake test:functionals and then you found that another part of the project your coworker is working on actually broke the test at an earlier place (another controller/action), before your functional test takes place. In this case, ...

Rails Cucumber URL hosts

So... I have this URL: example.com which works in my browser, cause in my hosts file i have it set to 127.0.0.1 example.com And that works in my browser... but not in cucumber. Any ideas? ...

ActiveRecord without setting up database tables? (declarative like Django)

In Django, you fully describe your models in models.py. In Rails with ActiveRecord, you describe part of a model in in the /models directory, and part of it in migrations. Then ActiveRecord introspects model properties from the existing database tables. But I find migrations, columns, and tables to be a headache. How can I do like ...

Rails Fields For Code Sample

Hi, Can someone explain the following code sample what does "album[photo_attributes][]" mean I found this code here http://infrastacks.com/?p=57 <div class="photo"> <% fields_for "album[photo_attributes][]", photo do |p| %> <p> <%= p.label :Photo %><br /> <%= p.file_field :data, :index => nil %> <%= link_to_function "delet...

Rails relational table with multiple id's from the same table

I know that if I name a column in a table "othertablename_id" rails will know to use that column for a belongs_to or other relation. If I want to have multiple id's from the same table, obviously this won't work, because I would have duplicate column names. What is the best way to build a table that relates two rows from the same table? ...