ruby-on-rails

Rails: How to treat some fields of model info independently? Eg. Account vs. Profile information.

I have a User model with the usual information (login, email, name, location, etc). However, when users decide to edit their information, I'd like to separate the fields to be edited according to the appropriate concerns. For example, I'd like to have Name, Bio and Location to be edited on a Profile page or tab, and login, email and pa...

XML Schema (XSD) to Rails ActiveRecord Mapping?

I'm looking for a way to convert an XML Schema definition file into an ActiveRecord modeled database. Does anyone know of a tool that happens to do this? So far the best way I've found is to first load the XSD into an RDBMS like postgres or mysql and then have rails connect to do a rake db:schema:dump. This however, only leaves me wit...

link_to_remote/Ajax.Updater broken in IE8 for a session?

So my issue is that Ajax.Updater doesn't update the divs I want to update in IE8 when using link_to_remote. Things work correctly in every other browser. The call completes server side, but the html div isn't updated. My code is as follows: link_to_remote( d.strftime("%d"), :url => {:action => 'show', :date => d}, :update => {:succ...

What parts of a Ruby-on-Rails application (with reasonably expressive unit tests) should have RDoc?

I'm developing an open-source web application on top of Rails. I'd like to make my code as easy to understand and modify as possible. I'm test-driving my development with unit tests, so much of the code is "documented" through test cases (what each controller action expects as input, what instance variables are set for output, how help...

ids in the form

hi, i have a event model that has_and_belongs_to_many artists class Event < ActiveRecord::Base has_and_belongs_to_many :humans, :foreign_key => 'event_id', :association_foreign_key => 'human_id' end in the form for the event inserting, i put an hidden field for the artists ids: <%= event_form.text_field :artist_ids %> If i insert...

How do I escape ERB code in fixtures?

Hi, I have a simple fixture.yml label: body: "<%= variable %>" The issue is that the erb code is parsed as part of loading the fixture, but I actually want to body to be "<%= variable %>" un-interpolated. How do I escape this? -daniel ...

(Rails, Warbler) Deploying and initializing Rails applications in Glassfish…?

Hi All, I posted this very same item on SERVERFAULT, but got no reply. So here goes: I'm currently in the process of finishing up a Rails application. I am using Warbler to package it up as a ".war" file and am using GlassFish to deploy it. I do this because the application is to be distributed to companies for in-house use. Arguably ...

Data Transfer Objects VS Domain/ActiveRecord Entities in the View in RoR

I'm coming from a .NET background, where it is a practice to not bind domain/entity models directly to the view in not-so-basic CRUD-ish applications where the view does not directly project entity fields as-is. I'm wondering what's the practice in RoR, where the default persistence mechanism is ActiveRecord. I would assert that present...

Does Ruby/Rails have a ++ equivalent?

I guess I just got used to saying things like: x++ in PHP and Java land. But when I tried this in my Rails code it had a fit: compile error /users/gshankar/projects/naplan/app/views/answers/new.html.haml:19: syntax error, unexpected ';' /users/gshankar/projects/naplan/app/views/answers/new.html.haml:23: syntax error, unexpected kENSU...

How do I show information attached to a model from another model?

I have just completed the introduction guide to RoR: http://guides.rubyonrails.org/getting_started.html. It's a great guide and everything works. I am trying to extend it a little bit by SHOWING tags in the Post view. (The guide sets it up so that you can add tags while adding a post even though Tag and Post are different models). This...

How can I display a "waiting" indicator on a web page whilst the http request is being fulfilled by the webserver?

Hi, Background - I have a web application for which a request takes several seconds. Question - How could I display a "waiting" type indicator (e.g. spinner) to the user after they initiate the request, until the actual HTTP request response comes back from the server? Notes - I'm assuming this to be a generic web development questio...

Multiple state machines in one model?

I have a model that represents a registration process, which needs to track the progression of several processes (background checks, interviews, information collection...). Each one can be represented by a state machine, and then the overall state of the registration might depend on the state of the others. Can aasm handle this? Any ...

Display logfiles in realtime using ruby

I need to display logfiles in real time to user webpage using ruby/rails. Users should be able to see logfile steaming without refreshing the page. Logfiles may not always be in the same machine which runs rails. Is it possible in ruby/rails ?. ...

Where to put methods that do simple date formatting

I have two models, BusinessHour and StaffHour that both inherit from Hour. In the BusinessHour and StaffHour models I do a 'find' to retrieve requested hours. After that I need to format each time to a specific format, which I have a method for. I'm trying to figure out where to put that method. It sort of seems like it would go in a H...

Using RackDAV to expose a webdav directory in a Rails app, how can I map the directory to serve up?

I am using RackDAV, and it's GREAT! http://github.com/georgi/rack_dav However, the only way I can get it integrated into my Rails app is to modify my server startup file, which I copied from /vendor/rails/railties/rails/commands/server file! Obviously not great. I have this working: app = Rack::Builder.new { use Rails::Rack::LogT...

How to keep track of model history with mapping table in Ruby on Rails?

dream I'd like to keep record of when a user changes their address. This way, when an order is placed, it will always be able to reference the user address that was used at the time of order placement. possible schema users ( id username email ... ) user_addresses ( id label line_1 line_2 city state zip ... )...

Rspec + Shoulda + FactoryGirl = undefined method `reflect_on_association'

I have Rspec + Shoulda + FactoryGirl and I am receiving the following error when attempting to call Shoulda's have_many or belong_to methods. All Shoulda methods used in the "validations" group work fine: > NoMethodError in 'A Project > associations should When you call a > matcher in an example without a > String, like this: > > s...

Mapping an array of records with depth values into nested Unordered List

Hi there, I hope this question hasn't been asked before: I'm using the ancestry gem to manage my tree structure. I'm using a function which returns the descendants of a node to a certain number of levels. Here's a simplistic example of what it's returning: [{:name => 'node 1', :depth => 1}, {:name => 'node 2', :depth => 2} {:name => '...

authlogic single access token

Hello, I am using Single access token to do some data transfer, so far I got it to work with one action in the controller through ProjectsController private def single_access_allowed? action_name == 'index' end But I need two more actions to be allowed access with single access token, I tried to modify the line action_name == 'in...

Editing multiple nested records simultaneously in Rails

I'm creating a simple quiz application where a question can have multiple answers. To improve the usability of my app, I want users to be able to edit ALL the answers for a given question in the same form: I found this great Railscast/Asciicast episode which does almost EXACTLY what I want to do http://asciicasts.com/episodes/198-edit-...