ruby-on-rails

Rails 2.3.9, adding ActiveScaffold, getting in `alias_method': undefined method `number_of_pages' for class `Paginator'

Hi, I have AS working in another app just fine (I dont remember this issue...) - its also using Rails 2.3.9, on same dev box. Now trying to add it to a new app and getting this error when running the webrick, script/server: /Users/kimptoc/.rvm/gems/ruby-1.8.7-p302/gems/activesupport-2.3.9/lib/ active_support/core_ext/module/aliasing.r...

A tension between DRY and performance?

I have a number of pages in my app that are showing partial FOUCs (flashes of unstyled content) upon loading, which occurs because some of them have stylesheets and/or javascript defined at the head of the document rather than in the layout. The fundamental issue is that the DOM is firing before these stylesheets are loaded. In order to...

Rails 3 - Controller Def Update, is not updating the record & Not erroring?

Here's is my permissions controller for DEF UPDATE: def update @permission = Permission.where(:user_id=> params[:permission][:user_id] ).where(:project_id=> params[:permission][:project_id]).first respond_to do |format| if @permission.update_attributes( params[:role_id] ) format.js { render :layout => false } else...

It is possible for my Rails App knows under wich context of HTTP is running?

In certain situations I run my app in a context like: /context/app , but sometimes I only use: /app In my DB I have an applications table that has an attribute for the path of the application (ex. /app ), what Im looking is that my app could determine in wich context is running in order to update that attribute (ex. /context/app) I th...

How to search an array in Ruby?

Say I have an array of strings arr = ['sandra', 'sam', 'sabrina', 'scott', 'mark', 'melvin'] How would I search this array just like I would an active record object in Rails. For example, the query "sa" would return ['sandra', 'sam', 'sabrina']. Thanks! ...

How do I remove a model and its table in Ruby on Rails?

Hello. I'm diving into RoR and I need to remove a model and its table, as well as update the other models that reference it. I did a search on google and SO and the best answer I found was this, but the answer is unclear to me. The final consensus was to use the ruby script/destroy model method and then "manually edit any migrations t...

AJAX form is not passing through params[:id]

I'm using a simple ajax toggle partial in a view, to allow a user to toggle a message as read vs. unread. When I toggle I get a failure. MessagesController#show could not find MessageCopy without an ID. Application trace: messages_controller.rb:21 in 'show' (first line of the action) show.html.erb <%= render :partial => "read_unread_...

Rails create action is redirecting to index when it should be rendering the new action

If I submit a new user form with errors, it redirects to the index page and then renders the new page on top of it. In the controller I specify that it should just render the new action so that the user can see/fix their errors and resubmit. Is there something obvious that I am missing? Here's the create action in my controller code: d...

What's the difference between 'ruby script/destroy model' and 'rails destroy model'?

What's the difference between ruby script/destroy model and rails destroy model? ...

Weird routing error in Rails 3.0

I've been converting my Rails 2.3.9 application to Rails 3.0 and everything has been going well. I've created a lot of routes with the new system so I feel like I know how to do this. However, I recently got a routing error I can't solve. I have a users resource defined like this: resources :users do member do get 'activate' ...

Elementary Rails deployment

I am trying to deploy my app on Rails for the first time using Heroku. I have spent quite a lot of time but there's a gap somewhere. Git: created private repo, pushed to git successfully Heroku: created free app and pushed successfully (but app 'crashes') Local: rake db:schema:dump #success rake db:schema:load RAILS_ENV=production #...

Disable html styles for select_date tag in Rails

Hi everyone Whats the best way to disable additional html generation for date helpers in Rails? Lets say i have a field on form <%= select_month(...) %> and it generates div class and new span inside. Is there a way to generate just the select html tag? Of course i can generate the whole tag by myself, but just wanted to know if thats...

How do I disable the popup box that says "Are you sure?" when I delete a row from my DB in RoR?

Hello. I'm diving into Ruby on Rails and I find that when I'm using the scaffold code that RoR generated for my model, it causes a confirmation box to appear that reads "Are you sure?" when I click on the delete link. What causes this to appear and how do I remove it? Thanks, I'm just trying to figure out how this all works. ...

Using Rack middleware for cross-domain sessions in same app

I have a white-labelled Rails app that allows me to create a variety of different new websites, each with their own TLD, but all powered by the same app. It's an ecommerce app so all orders are processed on a single, different TLD. For example, I might have three TLDs: domain_a.com domain_b.com domain_c.com and orders are processed o...

Defining an object's behavior using polymorphic inheritance

Hi all! Today I was faced with a challenge to create different behaviors for my shopping cart model. That's because the owner of the online shopping wanted to create some promotions like buy 1, get 5 or get 25% discount + some extra stuff, etc... I thought of doing it with polymorphic inheritance, where my Cart model will only hold the...

is it good to use S3 for Rails "public/images" and there an easy way to do it?

I'm somewhat new to S3. I'm wondering if it's a good idea to put public/images in S3 bucket and if so is there an easy way to do the move? ...

How can I generate Bitmap Pictures in Ruby on Rails

What's the best way to generate Pictures, Pixel by Pixel in Ruby on Rails. I have a two-dimenisonal matrix with all the color values for each pixel, which i want to vizualize. Something like this: myBitmap = new Bitmap(:width => Column.all.count, :height => Row.all.count) Colum.all.each do |col| Row.all.each do |row| #Draw the Pixel...

How do you make a form out of a polymorophic table?

I am trying to create a comment that could comment on other comments but are all derived from a single post. What is especially troubling for me is trying to figure out how to make it so that this can all be achieved in the post show and not its edit or new. Is this archtecturally reasonable? That way I can access it via Post.comments,...

How to get my rails pages to return as html?

I've written a rails site in the latest version of rails, based on knowledge of rails from a couple of years ago, and I've hit a horrible snag. I foolishly decided to ignore the new RESTful routing system and hope for the best. So all of my views are plain .erb, NOT html.erb my routes file looks like this map.connect '/crm/:action/:i...

Ruby On Rails: Couldn't find 'rspec' generator?

Hi, trying to learn ruby on rails at the moment and currently learning about testing. The tutorial I'm following uses rspec, so I ran the commands: sudo gem install rspec sudo gem install rspec-rails script/generate rspec only to get an error message "Couldn't find 'rspec' generator". I've searched for an answer on this topic but I ca...