ruby-on-rails

Getting undefined method `username' for #<UserSession: no credentials provided> with Authlogic after push to production

We've never gotten this app to run in production. The application runs just fine in dev. I've made sure all rake tasks are up to date and acts_as_authentic is set for the user and everything else that everyone has posted on all the forums. The server has been bounced multiple times. This error comes up every single time on all URLs. ...

Array to String Back to Array Conversion Problem

I'm saving a bunch of ID's to the session like this. session[:id_group] = 1,2,3,4,5 Because I need to save them to a data base with a form. In that form I have hidden-field : <%= form.text_field :group, :value => session[:id_group].inspect%> I use the inspect so that the value saved to the database gets to be [1,2,3,4,5] and not 1...

Help searching MYSQL database with a JOIN - possible self JOIN ?

In a View i have a table of users combining data from multiple database tables. The important tables are Users and Invitations. Im performing a join LEFT JOIN invitations ON (users.id = invitations.invitee_id) which gives me access to users.invitee_id, but i also have dynamic search parameters in my query and i cant search for an invi...

rails button_to :disabled => true still displays the button

I would like to display a button but in a disabled state,to show the user that they already saved an item. I currently used something like: <%= button_to 'Save', :disabled => item.is_saved? %> The generated html looks like: <form class="button-to" action="/results/save_item/748?class=buttons&amp;disabled=true" method="post"> <div>...

Rails ActiveRecord associations inconsistently updated

I am running into some Rails 2.3.5 ActiveRecord behavior I do not understand. It appears that an object can have its association ids updated in inconsistent ways. This is best explained with an example: Create a Post model with the string attribute 'title' and a Comment model with the string attribute 'content'. Here are the associa...

Making the Cross-Site Request Forgery token live longer in Rails

In an application I make I'm getting lots of these messages: A ActionController::InvalidAuthenticityToken occurred in items#vote_up: ActionController::InvalidAuthenticityToken /var/lib/gems/1.8/gems/actionpack-2.3.4/lib/action_controller/request_forgery_protection.rb:79:in `verify_authenticity_token' which I suspect it's happening...

find condition issue

min_age = params[:min_age] max_age = params[:max_age] @users = User.find(:all, :conditions => [" years >= ? AND years <= ? ", min_age, max_age]) This is the controller method for a search feature. As you can see I wish to search by age range. This works for all max_age values up to 99, but when the max_age exc...

Unit testing paperclip uploads with Rspec (Rails)

Total Rspec noob here. Writing my first tests tonight. I've got a model called Image. Using paperclip I attach a file called photo. Standard stuff. I've run the paperclip generator and everything works fine in production and test modes. Now I have a spec file called image.rb and it looks like this (it was created by ryanb's nif...

When working with gems in Rails, what does 'cannot remove Object::ClassMethods' stem from?

Frequently I have run into a problem when installing gems that provides a problem like: Does anyone know what this stems from? I've seen in it several different cases, yet still haven't learned what exactly is causing it. $ sudo rake gems:install --trace (in /u/app/releases/20100213003957) ** Invoke gems:install (first_time) ** Invoke ...

How do I make yahoo unblock the images that come with the emails coming from our server?

How do I make yahoo unblock the images that come with the emails coming from our server? ...

take the table element while clicking on the same table element

I'm developing a project and I have a problem about this subject. I'm constructing ruby on rails project which will provide listing students with name. First of all , I will list my students information in a table and one part is missing. When the user clicks on Student Name , another table will appear and show the other information o...

What is rack middleware?

Hi, What is rack middleware? Thanks. ...

How do I return memcached string based on respond_to type?

I have a group of categories and I access these categorizes via javascript several times during the average course of use for my application via JSON. So in my control currently I have a @categories = Category.all respond_to do |format| format.html # index.html.erb format.json along with the appropriate index.json.erb file that...

AJAX + RAILS Problem with ShowTooltip window effect...Routing Error in Rails

AJAX + RAILS Question. Am getting a Routing error for the following: <div class="card-field"> <h6><imgsrc="/images/red_icon.png" width="16" alt="" align="absmiddle" class="image-3" onmouseover="ajax_showTooltip(window.event,'/quickadd_notes_help.html.erb?ranId='+Math.random(),this,'','');return false;" /></h6> <p>Company Name:</p>...

Prevent File Download, RoR

I'm using Ruby on rails and I have videos that I don't want users to download. Where do I store the videos? From the name of the folder "Public" maybe this is a really stupid question, but is that an ok ok place to store the videos? ...

Smarter paperclip validations

I'm using paperclip in a rails app and have the following three validations in my model validates_attachment_presence :photo validates_attachment_size :photo, :less_than=>1.megabyte validates_attachment_content_type :photo, :content_type=>['image/jpeg', 'image/png', 'image/gif'] If the user forgets to add an attac...

Rails: generate a full URL in an ActionMailer view

I'm using ActionMailer to send a sign up confirmation email. The email needs to contain a link back to the site to verify the user, but I can't persuade Rails to generate a full URL (including the domain etc). I'm using: <%= url_for :controller => 'login', :action => 'verify', :guid => @user.new_user.guid, :only_path => false, :host =...

Rails validations running against original record during update

I'm trying to figure out an inconsistency between what's happening in a functional test and what is happening in my development environment. I have a custom validation method unique_entry that is essentially a specialized version of validates_uniqueness_of. It looks like this: def unique_entry matched_entry = Entry.first(:conditions =...

Rails Routing with Query String

I have a problem where I need values passed in from a GET request and I don't know how to set up the routing definition. My Category object has a type(string),a color(string) and many products. I want to create a simple web service that lets the caller get all of a Category's products by passing in the Category's type and color: http:...

Looking for records of the current month with a DataMapper query

Hi, I'm trying to reproduce this SQL query I used with ActiveRecord: Post.all(:conditions => ["EXTRACT(MONTH from created_at) = ? AND EXTRACT(YEAR from created_at) = ?", month, year]) But since I'm converting everything to DataMapper I was looking for a way to do this... Can anyone help? ...