ruby-on-rails

Rails After Validated Save Go to Edit Path

This seems like a fairly simple problem to me but I have been having some issues. In one of my views I use something like <% if current_page?(:controller => "activities", :action => "new") %> *Do something here* <% end %> and it does something specific on the new page for a form. Easy enough and it works great. Unfortunate...

render partials in actionmailer templates

I am trying to use an existing partial in an actionmailer template, something like.. My merchant_offer.txt.html.erb <%= render :partial => "offers/offer", :locals => {:offer => @offer} %> Notifier.rb (my mailer class) def merchant_offer(offer) subject "New Offer from #{offer.merchant.name}" from "[email protected]" ...

Eager loading polymorphic associations with different has_one associations in Rails 2

ActiveRecord gives you an interesting error when you try to eager-load a non-existent association. It looks something like this: ActiveRecord::ConfigurationError: Association named 'secondary_complaint' was not found; perhaps you misspelled it? Now why the hell would anybody want to preload a non-existent association? Check this out. ...

Getting invalid Nil Object Exception when creating RSS feed in Rails

I'm creating an RSS feed for user notifications, each user has a feed unique to them which they get from a unique URL. The problem is that @notifications (set in the controller) is giving said to be a nil object, but @notifications both exists and contains data. Here's the controller code: def user_notifications render :layout => fa...

Using liquid with haml

Hi All, I'm planning to develop a CMS with ruby/rails. One of the main key features that I'm planning is to give the user to edit their layout (I'm planning to do this through liquid) meanwhile i have red some good articles on HAML and SaaS. So just wondering whether i can use haml + liquid + sass for my work If possible i would thank...

Newbie Web Designer needing Advice for Ruby on Rails

Hi, I have been designing small and simple sites for years now, I have somehwat experience of PHP but I have good grasp over HTML and CSS and on Wordpress. Now, I want to try my hand on Ruby on Rails as well, just to get a hang of it and to be able to edit pre-written code. Please help me where to start and what to learn first, includ...

Setting up Subdomain-Fu in Production Environment?

I'm using the popular subdomain-fu for subdomain functionality in my Rails app. I've watched the Railscast and read everything I could find through google. In the dev environment, you need to manually add the available subdomains to the /etc/hosts file. I get that. But how does this work in production? This seems to be considered ...

In Ruby on Rails, how can I map all actions in a controller to root?

In Ruby on Rails, how can I do the equivalent of this in a more elegant routes line? I may have to add many of these... map.connect '/about', :controller => "site", :action => "about" map.connect '/contact', :controller => "site", :action => "contact" map.connect '/preview', :controller => "site", :action => "preview" Thanks! ...

How to call a javascript post render in Rails ?

This is the facebox popup content <div class="form_container"> <% form_remote_tag :url => { :action => 'custom', :d=>params[:day], :h=>params[:hour] }, :class => 'general-form', :update => 'grid['+params[:day]+']['+params[:hour]+']', :success => 'handle_success('+params[:day]+','+params[:hour]+')' do -%> <...

Extensible Rails application that connects to several databases

I am implementing a Rails application that needs to aggregate search results from N independent heterogeneous databases. An example use case would be: User queries "xpto" The query is submitted to all the databases registered on the system The results are transformed and combined in a predefined format User gets the results The appli...

declarative_authorization and namespaces

Hi, Do you know - can declarative_authorization control access to namespace'd resources or not? I've tried something like has_permission_on [:admin, :users], :to => [:index, :show, :new, :create, :edit, :update, :destroy, :search] but it's not working :( any ideas on this? ...

Active Record joins over 3 tables

Hi, I am trying to find all terms and courses that apply to a contact. Here are my models class Register < ActiveRecord::Base belongs_to :session belongs_to :contact end class Session < ActiveRecord::Base belongs_to :term belongs_to :course has_many :registers has_many :contacts, :through => :registers end Here is the find...

Using harsh with generated code

I have code in @snippet.code, and I want to highlight it with harsh: :harsh #!harsh theme = lazy = @snippet.code However, this just highlights @snippet.code, so the output is: <pre class="lazy"><span class="Keyword">=</span> <span class="Variable"><span class="Variable">@</span>snippet</span>.code&#x000A;</pre> How can I use Ha...

Handling Active Resource Error

Hi. I have a simple question, and I am sure there is a standard answer to it; just can't find it. I have an ActiveResource user model in my rails app. It points to another rails app where my actual user entity lives. Everything in my app works fine while both apps are up. But when my back-end rails app is down; and I try to access activ...

Ruby Displaying objects

UPDATE my show function def show @contact = Contact.find(params[:id]) @data = Register.all :include => {:session =>[:term, :course]} , :conditions => ["contact_id = ?", params[:id]] respond_to do |format| format.html # show.html.erb format.xml { render :xml => @contact } end end Models class Register < ActiveRecord::Base bel...

Problem in setting up sphinx.

Error i m getting is:- mohit@mohit-laptop ~/Desktop/code $ rake thinking_sphinx:index (in /home/mohit/Desktop/code) Generating Configuration to /home/mohit/Desktop/code/config/development.sphinx.conf Sphinx 0.9.9-release (r2117) Copyright (c) 2001-2009, Andrew Aksyonoff using config file '/home/mohit/Desktop/code/config/development.sph...

Routing Sub-Controllers

My route looks like the following: map.namespace(:admin) do |admin| admin.resources :pages end and my controller name looks like the following: class Admin::PagesController < ApplicationController and my new.html.erb file looks like the following: <% form_for(@page) do |f| %> <%= f.error_messages %> <p> <%= f.lab...

XML Builder in Rails: 'wrong number of arguments' bug that I just can't trace

Hi folks, New to rails, and I've just spent hours trying to hunt down a bug. Any help very appreciated. I'm trying to make a rails page so that if a user enters /info/who_bought/1 the page outputs HTML, and if they enter /info/who_bought/1.xml, the page returns an XML file. (In short, I'm doing chapter 11 from the 'Agile Web Developmen...

Ruby framework to write a API in?

Hi I'm looking to write a multiplatorm tasks application for technical people. I want to handle as many platforms as I can (web, shell, desktop) and therefore I have decided to begin with a server/API. I want to write it in Ruby, however i think that Rails is a bit too heavy for this, even though it would do the job. Sinatra also doesn'...

Moderated model editing in Rails2

I want to allow users to edit a model, adding a picture, url and/or phone number to it. However I don't want these changes to show up until they are confirmed by a moderator. I do however want to allow the users to create new entries without moderation, but they cannot include the picture, url, and/or phone number (they can include basic...