ruby-on-rails

losing session in rails 2.3.2 app using subdomain

i have a 2.2.3 app which i upgraded to 2.3.2 it's a multi-site (using subdomain) that creates one top level session for all sites. this is how i change the domain in production.rb: ActionController::Base.session_options[:domain] = "xxx.com" # in rails 2.2.2, this is what i used to do: # ActionController::Base.session_options[:session...

Stubbing Chained Methods with Rspec

I want to call a named_scope that will only return one record, but the named_scope returns an array, that's not a big deal as I can just chain it with .first: Model.named_scope(param).first and this works, what I am struggling with is how to stub the chained call. Does anyone have a reference or an answer on how I would go about achie...

Using acts_as_list with has_many :through in rails

I have a rails app I'm trying to set up with sortable lists using the acts_as_list plugin. The position field in the db is getting updated, but when the page is rendered, the order is not considered. I'm looking for some help, I guess. Here are my models... class QuestionMembership < ActiveRecord::Base belongs_to :form belongs_...

Switching test::unit with rspec under rails

Kinda odd question here: when you go with rpsec instead of test::unit on rails, what do you do with the test dir? Keep it (for any compatibility issues maybe?) or remove it? ...

Rails editing the HTML in views

I'm doing a tutorial from Head-First Rails (via Safari Online) and cannot get edited HTML to show up in the browser (the changes, I mean). Specifically, I'm just changing the label for one of the columns from "Seat seq id" to "Seat #". I've opened the four view files, edit, index, new and show.html.erb. Everywhere there's an 'f.label :se...

Rails 2.3 migration issue with helpers

Hi, I'm migrating a plugin of mine that uses engines plugin. In my plugin there is a helper wich is not being recognized by rails. Does anyone knows any issue related? Thanks ...

How can I detect if an html page element exists by using RoR RJS Template code?

I tried several ways but all are failing. ...

Ruby relative_path_from call on Windows

I'm running into an issue with the portion of the Rails generation script that searches the plugin path for appropriately named files to find generators. On one of my systems, I have Ruby installed in c:\dev\ruby and have my project directory at d:\local\projects The Ruby Pathname#relative_path_from method (which is called by the Rails ...

IS there any application controller for .net mvc like ruby on rails?

I have some navigation things that need to hit the database every time a page has been requested. In Rails I would just set an instance variable in the ApplicationController.rb and that would be available to every controller/view. Now I see that all my controllers inherent from : Controller in .NET MVC. Can I open a partial class for Co...

Routing in Rails

Hi everyone, I'm designing a minimalistic wiki in RoR. Basically a project have many pages. My routing file looks like this: map.root :controller => "projects" map.resources :projects, :has_many => :pages map.connect ':id', :controller => 'projects', :action => 'show' map.connect ':project_id/:id', :controller => 'pages', :action => 's...

What is the best approach to monitor site performance in rails

I'd like to have a special part of administrate area which shows a list of pages/queries that was slow for the past week. Is there a gem / plugin or other easy way to implement/automate such functionality for the Rails framework? ...

Passing a model attribute to a Rails view using redirect_to

Hi- I'm trying to pass a model attribute to a view, after successfully setting it to a new value from inside an action in my controller. But this variable is always nil by the time it gets to the view, so I can't use it to conditionally display stuff. I should add that this attribute is not a field in the database. What am I missing/doi...

How do can you make redirect_to use a different HTTP request?

At the end of one of my controller actions I need to redirect to a page that only accepts put requests. I have been trying to figure out how to get redirect_to to use a put request but to no success. Is this possible? Or is there another way to accomplish this? Thanks. ...

Bug in pluralize and testing?

Hi, I have a model called TipoContato (table tipos_contato), if I pluralize this it will become tipo_contatos, so I added this to inflections: inflect.irregular 'tipo_contato', 'tipos_contato' OK, testing it in console it is perfect: >> TipoContato => TipoContato(id: integer, descricao: string, created_at: datetime, updated_at: date...

Rails: get to parent resource

I got a config/routes.rb file like this: map.resources :categories, :shallow => true do |cat| cat.resources :entries, :member => {:yes => :post, :no => :post } end My goal is use yes and no as buttons that modify my entries (it is like a game, and yes and no are answers to the entries). I would like that when I click on yes...

Rails ActiveRecord: Inserting text containing unprintable/weird characters

I am inserting some text from scraped web into my database. some of the fields in the string have unprintable/weird characters. For example, if text is "C__O__?__P__L__E__T__E", then the text in the database is stored only as "C__O__" I know about h(), strip_tags()... sanitize, ... etc etc. But I do not want to sanitize this SQL. Th...

Is there a way to change map.root to point to something other than '/'?

I have apache 2.2 with mod_rails running at http://localhost. I want to have my rails app at http://localhost/railsBlog. So, what I did was, I created a virtual host: ServerName localhost DocumentRoot /Library/WebServer/Documents RailsEnv development RailsBaseURI /railsBlog Now, since the URL is http://localhost/railsBlog, ...

Ruby on Rails: New controller for photos?

I have a one-to-many relationship between my Profile class and Photos class. Profile holds the user's information and photos holds the user's pictures. Currently, the "Upload photo" link shows at the bottom of the profile view. I want to have the link show up on a separate view instead of cramming everything on the same form. Should I ju...

How to prepare to be tech crunched

There is a good chance that we will be tech crunched in the next few days. Unfortunately, we have not gone live yet so we don't have a good estimation of how our system handles a production audience. Our production setup consists of 2 EngineYard slices each with 3 mongrel instances, using Postgres as the database server. Obviously a hu...

Consuming XML/SOAP web service in RoR

I know they removed ActionService out of RoR and opted for RESTful web services. I want to know if Rails is a good choice of a framework for consuming XML/SOAP based web services. Can anyone point out some nice resources/tutorials on how to consume a SOAP based web service in ROR? ...