ruby-on-rails

Rails rack 1.0 error

Hi! I have this error when I try to start script/server: /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems.rb:827:in `report_activate_error': RubyGem version error: rack(1.0.0 not ~> 1.0.1) (Gem::LoadError) from /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems.rb:261:in `activate' from /opt/ruby1.8/lib/ruby/site_ruby/1.8/rubygems.rb:68:in `ge...

Ruby on Rails Else If Question

I have an application where in the layout I have a user_name div which will display different things based on whether or not they are logged in, are an admin, etc. Right now my code is the following: <% if current_user.role == "admin" %> <p id="admintxt">You are an admin!</p> <%= link_to "Edit Profile", edit_user_path(:current...

:has_one relationship problem when using MongoDB

I have a pretty simple setup. To sum it up here's what I'm doing: class Movie include MongoMapper::Document has_one :setting end class Setting include MongoMapper::EmbeddedDocument belongs_to :movie end What I want to do is to update the setting of a movie in the same form as the movie other information. Therefor I do that : ...

Ruby ERB not reflecting changes

I'm trying to change an ERB to remove the line <div id="header"></div> However, the resulting div tag still appears on the page, even 30 minutes after the fixed file was uploaded to the server. The server is running Ruby 1.8.6 and Rails 2.1.2, and the affected files (two_column.html.erb and three_column.html.erb) were downloaded from...

AJAX Layout Blues: Rails renders full HTML where partial should be

NOOB here. I'm trying to render a partial (refresh the results when someone clicks on a check box) but for some reason rails keeps loading the full page where the partial should be! I know this must have something to do with a misplaced or nonexistent :layout => false, but I have no idea where to fix it. THanks! Code: Controller: ....

Paperclip::NotIdentifiedByImageMagickError when file is not a valid attachment content type

Hi, I have systematically an error when I'm trying to upload a file that is not in ["image/jpg", "image/jpeg", "image/gif", "image/png", "image/pjpeg", "image/x-png"] When I try to upload a file like a wav I have this message * Photo /var/folders/nT/nTr21TWfFRO7r3cyG-h-7++++TM/-Tmp-/Clip audio 01,39154,0.wav is not recognized by the 'i...

Extra fields with custom rails form builder

I have a custom form builder, and one of the reasons for this custom builder is that for every form, I need to include some extra params that I don't want to explicitly put in with hidden field tags in every form I write. for_for(@foo, :builder => MyBuilder) do |f| # stuff I shouldn't have to worry about # this should be put in all ...

Rails plugin not loading in script/console

I am using http://github.com/mbleigh/acts-as-taggable-on/ in a rails project. I am using the plugin version because I can't get the gem to work for the life of me. Everything is fine in the normal use of the plugin. When I try and use the model that is referencing the act_as_taggable_on method of the plugin in the console it freaks out. ...

Print a List of All Tests in a Rails App

Is there an easy ruby or rails command to get a list of all the tests in an application? I use Shoulda primarily, but if there's a ruby solution regardless of test suite that would work too. ...

Deactivate feature using cucumber

I want to exclude one, already written feature when running all my cucumber features. Why? Because the feature is already implemented (bdd) but I don't have time to implement it now, but I don't wanna loose it. Any help is very appreciated. Code sample: @shallbeexcluded Feature: Exclude me In order to learn more As an stack overf...

Restful Authentication -- Relating User ID to Profile

Hey Guys, I'm new to Ruby on Rails...I've been playing around with developing a social networking type app....I just added Restful Authentication to my app successfully..Now I would like to create a model/controller where each User once logged in can create/edit their own profile. So I created the model and controller...the code in th...

How to validate user input in RoR?

I really don't know advice with validating user input. I'm begining with RoR. I read many pages about this issues, but I never get, what I want. Before RoR, I programmed in Java. My problem is: How I can do validate empty field and show error messages? Here are code fragments: polls_controller.rb class PollsController < ApplicationCont...

Should I be using Rails or Ruby for this website application? How?

Hi all, I'm very new to web programming (or actually, very old to it, since the last time I messed with the web was HTML 1.1), but now need to deploy a web application quickly. It seems like every time I turn around, there's new acronyms and technologies to learn (JSON, XMLRPC, GWT, Javascript, Rails, etc). Here's what my app must do:...

How do I create a 'Most Recently Popular' bar for content in Ruby on Rails?

I'm a noob so please forgive if this is an easy question but I'm trying to create a 'Most Recently Popular' output for specific content on a rails project. Right now the object I am pulling from has an attribute revision.background_title. I want to calculate popularity by finding the number of specific background_title's added over the...

Why is Ruby throwing a Segmentation fault on only my system, and only in this Rails application?

I'm not exactly sure how to properly debug this but have tried a few different approaches that have chewed up time, but not solved the problem. At least 4 other people in my office can execute this code on identical machines with the same version of ruby and rubygems installed with no error. Here is the code that I'm executing: status ...

Micro-refactoring: creating a hash for JSON from objects

Hey, thanks in advance for the help. I have another pretty straight forward question. This isn't very rails-like, but it works. Is there a way to do it better? I know there's group_by, for dates, but I can't figure out how to use it for this. I'm still super new at ruby, but know enough to tell that there must be a better way! def self...

How to unit test delete operation on a bunch of records using flexmock

I am using rails 2.3.5 and here is the main action in my controller. @klass.paginated_each(:conditions => @cond ) do |record| klass.send(:delete, record) end Here is my functional test with shoulda and flexmock context 'xhr advance_search with delete_all action' do setup do flexmock(Article).new_instances.should_receive(:de...

What happens to active user sessions when you redeploy an application?

I'm moving to ruby/rails from php, and one of the things I've always been curious about is that in php if I want to make a live change, I can simply edit the file, click save and it's active (assuming I'm editing on live env); no application redeploy or downtime for my users. With rails, almost any change I make, requires the applicatio...

Nested named routes in rails?

Lets say you have a two models with blog posts and comments set up like this: class post has_many :comments and the routing was set up pretty much the same way: map.resources :posts, :has_many => :comments When I go to make a new comment it shows up as localhost::3000/postname/comments/new What should you do in order to make the ...

has_one :through through a join model

Hello all, I want to build something so that a person can have many email addresses and an email address has only one person, but because I also have another model called Company that also can have many email addresses, and I don't want to have columns company_id and person_id in the Emails table, so I thought I can do ... person.rb ha...