ruby-on-rails3

accepts_nested_attributes_for in combination with formtastic and paperclip

Hi guys I am trying I have a simple one-to-many association. I am trying to update photos that belong to an album through a nested form: The edit form for the photo album: <%= semantic_form_for(@album, :url => user_album_path(@user, @album), :html => {:method => :put} ) do |f| %> <%= f.inputs do %> <%= f.input :title %> <%= f.in...

Where do I put Sinatra files intended to be embedded in a Rails3 app?

I want to use the new Rails3 feature that allows you to embed a Sinatra app inside rails. In my routes file, I have: # app names changed to protect the (not so) innocent MyApp::Application.routes.draw do match "/service", :to => MyService ... end And in /lib/my_service.rb I have class MyService < Sinatra::Base get "/" do "...

Rails 3 UJS is making it difficult for me to create a "Back" button

I have a basic search page that replaces html in a div with the search results. Clicking on one of the search results brings up a detail page. And I have a link on that detail page that says "Go back to search results". My problem is that it just generates a link to the root_url. Is there a way I can generate a valid back link to thos...

Nginx Passenger 3.0 "LoadError" in Production

I have been battling with this question for the past couple of days. I have never been fortunate enough to have to install a Rails application on production and have been pulling my hair out over these errors. My application is currently running http://typealoud.com and throwing an exception which basically amounts to a "LoadError" in a ...

What is the Rails 3 Way to do a form field validation prior to submission?

I basically want to prevent searches that are less than 3 characters long. In Rails 2.x, I would just do this in an onClick event. I understand how to handle AJAX requests and responses in Rails 3 now, but wouldn't using the onClick event be considered obtrusive in Rails 3? ...

Rails Devise login system. How to customize login flow?

I have been using the devise gem for rails and I have facebook login system working. My problem is that there is so much going on in the background that I find it difficult to customize this. For example how do I change the path to the page the user is redirects to after the first time facevbook login, not the usual facebook login. It a...

Exim piping for forwarding to rails controller

Hi, I am using Exim. I am trying to "send" all emails to a rails controller, but unfortunately I have no experience with Piping emails. Any help with the configuration of Exim is welcome. What i want is that Exim should forward all emails that are going to "bounce", because no such user exists, to the script ...

Error reprocessing in Paperclip 2.3.5

I updated from 2.3.3 to 2.3.5 for the string to array bug, and now when I try to call Model.image.reprocess! I get the following error. Is this something in my code or something in paperclip? Or maybe in the image I'm uploading? "\xFF" from ASCII-8BIT to UTF-8 /home/brian/.rvm/gems/ruby-1.9.2-p0@sp/gems/paperclip-2.3.5/lib/paperclip/sto...

I need to specify a field name different than the table for association

Given I have an Artifact model and a User model: I would like to define two Artifact fields, opened_by and assigned_to, who values are User ids and inherit all of the proper association methods. What is the proper belongs_to or has_one or has_many options I should set? The goal is to be able to reference the user's name through the s...

How to make passwords optional using Devise?

How can I make the password optional into the registration and login when authenticating a user (if no password then it will just use the e-mail) using Devise. Although if they register with a password (or update it later) it should then be require for login. How can I accomplish this using Devise? Note: I'm using Rails 3.0.1 and Devise...

Rails In Place Editing

Hello, I'm using rails 3 and am trying to use the in_place_editing plugin: http://github.com/wanglian/in_place_editing # Controller class BlogController < ApplicationController in_place_edit_for :post, :title end # View <%= in_place_editor_field :post, 'title' %> However I'm getting the error: id for nil, which would m...

Rails3 : "yield multiple times in one layout and use block arguments to differentiate the section does not work" as mentioned in documentation

I am trying to achieve something similar to what is shown in the Rails 3 documentation "You can also yield multiple times in one layout and use block arguments to differentiate the sections." <%# app/views/users/_user.html.erb &> <div class="user"> <%= yield user, :header %> Budget: $<%= user.budget %> <%= yield user, :footer %> ...

Rails: create parent, using parents own view, while creating child record

While part way through entering a new record(child), that is incomplete and can't be saved, I want to be able to add a record to another model(parent) and then use it to complete the original record(child). The parent has many required attributes, not just a single field. I want to do it in as dry a way as possible using the new/create v...

XHR doesn't work because "Origin is not allowed by Access-Control-Allow-Origin".

I'm working on a API-Server with Rails 3 wich is pretty handy so far but I'm running across a error all the time and I'm not sure wether it is because of my Apache Setup or the Rails App. When I try to do a HTTP DELETE or PUT request on http://sample.domain/uri/id via XHR, curl or HTTP-Client.app Rails or Apache responds with 404 or 403...

Stubbing Chained Queries in Rails 3 and Rspec

I'm trying to test a scope I have that is based upon a chain of other scopes. ("public_stream" below). scope :public, where("entries.privacy = 'public'") scope :completed, where("entries.observation <> '' AND entries.application <> ''") scope :without_user, lambda { |user| where("entries.user_id <> ?", user.id) } scope :public_stream, l...

Rails - News Feed

Alright here's the trickiest question I've ever had to ask on StackOverflow. My Web App allows creating a document. This document is automatically saved lets say ever couple of seconds. Meanwhile, I want a news feed to lets users know what there friends are up to. So I created a observer model which after_create creates a news_feed typ...

Restrict characters entered into a text_field

I have a text field where users enter a URL string, which cannot contain spaces or non-alphanumeric characters (if that's an accurate way of putting it). Is there a way in Rails to restrict entry into the text_field itself so that spaces and characters like /":}{#$^@ can be avoided? Thanks a lot. To clarify, the only characters that...

rails, image upload and resize with imagemagik

I made a small piece of code to upload a file and then resize it with imagemagik. I am using the system("command") function to call imagemagik to resize the image, but the output is a file of size 0 bytes. any idea what could be going wrong? ...

No such file to load --openssl

I Am using ruby 1.9.2 (without rvm) and rails 3.0.0 on Ubuntu..when i am trying to run the server following error is coming: No such file to load --openssl... I am new to ruby on rails so plz help me out... ...

spork on Win7-x64/ruby1.9.2p0?

Having trouble getting spork running on Win7-x64/Ruby1.9.2p0: gem install spork ERROR: Error installing spork: ERROR: Failed to build gem native extension. C:/Ruby192/bin/ruby.exe mkrf_conf.rb Actually, there aren't any native extensions. I'm just dynamically installing dependencies based off of your operating system rake RUBYA...