ruby-on-rails

Capistrano install directory problem

I'm doing my first Rails deployment and using capistrano, following my host's directions: I have the domain plantality.com. I've created the gws folder for my app. I've installed with capistrano and followed all the wiki instructions I could find. public_html is pointing to gws/public but capistano has installed my app to gws/current...

Ruby On Rails Development Machine

Hi Folks, I'm starting with Ruby-On-Rails development on Linux machine. I want to know which Linux distribution will be best suited to do ROR development. Also what will be the best (free) IDE for ROR on Linux. ...

Check if Services/APIs have Expired Their Content - Best Practices for Optimizing/Caching Service Usage?

If you want to build a website/mashup using 10+ services (twitter, facebook, linkedin, github, stackoverflow, etc.), and you also want to optimize your application... Can you check if a URL's content is expired, without having to GET all of the pages content? If you could do that, then you could keep a local cache of their content in y...

load partial with jquery and rails

Im curious about what the best way to load a rails partial with jquery. So far I have tried a solution not working: $('#imagecontent').load('/newsletters/_image_gallery.html.erb', function() { alert('Load was performed.'); }); Is the best solution to build a seperate action and/or controller for this and set up a route? Im asking beca...

rails ODBC data source problem?

Here's an odd situation, if I open a command prompt and start the mongrel server then everything works swimmingly. ActiveRecord talks nicely to the MSSQL server using ODBC if I have a User-DSN defined. But if remove the User-DSN and set just an identical System-DSN then odbc bombs: [Microsoft][ODBC Driver Manager] Data source name ...

Using respond_to ... format.json and jQuery Form Plugin by malsup

Hello all, I'm having a tad bit of trouble getting the jQuery Form Plugin to work properly with a file-upload field. When I use the plugin to submit the form without a file-upload field, the format.json portion of the respond_to do |format| block is called properly. However, by adding the file-upload field, it only executes the format.h...

Rack-Bug panels won't appear in my Rails app

I've installed Rack-Bug for my Rails app, but can't get the panels to appear. project: http://github.com/brynary/rack-bug additional instructions: http://wiki.github.com/brynary/rack-bug/security yet more instructions: http://stackoverflow.com/questions/1912983/rack-bug-installation-issue-server-does-not-start (the docs really suck for ...

Algorithm for sorting a nested/adjecency model in Ruby

I've been trying to find a good way of doing this, either on the client side in Javascript or at the last minute within the server. This is a Rails application but it is a pretty generic question. I have a model that is hierarchical, and is currently stored in a nested set model. The model then has: parent_id, lft, and rgt I would lik...

Rails - Special Characters converting to ??? when saving

Just trying to handle special characters into a string field on my model. When it saves to my Oracle database which is set to AL32UTF8 it is converting them to ??? Tiny-mce is hooked up on one of the other fields and I was able to configure it to convert a backwards apostrophe for instance to ‘ Just need to decode / convert m...

Rails/jquery passing a variable(IDs) collected in jQuery to a rails controller/action

Hi everybody, I am new to AJAX and jQuery so please excuse me if this is kind of basic: I implemented the great jgrid by 2dconcepts (http://www.2dconcept.com/jquery-grid-rails-plugin). Now I would like to select the data in my table with the checkbox, - get the product ids (that works fine I see the alert from the 'handleSelection') ...

Nested RESTful routes in Rails: how should I organize my views?

Lets say you have an Invoice resource, and each Invoice has nested InvoiceLine resources, i.e. a very common nested resource pattern. Now, where should one put the view for showing each individual invoice line as a row within the invoice? Should invoice lines be rendered as a partial under invoices/_line.html.erb, or should they get the...

[Rails] Cannot access with_scope from a mixin

I just stumbled over a weird problem, and I don't really understand what is causing this. In our rails app, let's have a mixin Mixin: module Mixin def foo with_scope :find => ... do ... end end end which is includeed into a model class elsewhere: class Model < ActiveRecord::Base include Mixin ... end calling ...

ActiveRecord :include not working for belongs_to with foreign_key

I have a two models set up like this: class User < ActiveRecord::Base # external_id column in database end class UserUpload < ActiveRecord::Base belongs_to :user, :primary_key => "external_id", :foreign_key => "external_user_id" end However, whenever I do upload = UserUpload.find(id, :include => :user) The sql that gets emitte...

Does ActiveRecord save a belongs_to association when saving main object?

If I have two models: class Post < ActiveRecord::Base belongs_to :user end and class User < ActiveRecord::Base has_many :posts end If I do: post = Post.new user = User.new post.user = user post.save Does the user get saved as well and the primary key properly assigned in post's user_id field? ...

accepts_nested_attributes_for to update another table

Is there a way to use accepts_nested_attributes_for to update another table from within a controller. For example, I have this in my students controller: def student_fail @student = Subject.find(params[:id]) if params[:id] @student.build_student_fail end def student_fail_finalize if @student.update_attributes params[:student] @subjec...

How do I write and test password changes when using Authlogic?

An application I inherited has the following action for updating a user's profile: class UsersController < ApplicationController # ... def update @user = current_user if @user.update_attributes(params[:user]) flash[:notice] = "Successfully updated profile." redirect_to root_url else flash[:error] = "Hrm...

Returning from viewing a record to that specific record in a paginated data set

I have a simple Rails app and for example purposes we'll say I have a customer model. If I have 1000 customers and I'm on page 6 when I click to view the details on a specific customer, what would be the best method so when I click a "Return to list" link, that it takes me back to page 6 and possibly even does a scroll to an anchor that...

Database design to store notifications to users

I'm working on a literature community website. (screenshot) And I'm trying to figure out how to notify users when someone comments on something they posted to the site, when someone they are watching submissions a new literature peice, etc. I'm trying to figure out how to structure the database to store this information. I've come up w...

Getting Rails out of the way?

I have a legacy app that was built entirely in jQuery and HTML. Does a lot AJAX calls and so forth. I needed an authentication framework for it, so I wrapped it in a Rails app. Rails -> does the authentication jQuery/HTML -> all the rest The problem is that the jQuery stuff doesn't seem to work anymore. All my regular AJAX calls...

Rails: Paperclip & previews?

You know on some sites when you're asked to upload, say, an avatar, you click on the button, select your file, then hit OK, but before you Submit the page (as in, no record is created/updated), a little preview of the image shows up? How would I accomplish this using Paperclip for Rails? Bonus points for anyone who can point me towards...