ruby-on-rails

does RoR develpment need shell access?

let's say that RoR development environment is set up and working does the developer need shell access to develop the RoR application? would ftp be good enough? why? I don't want to give my future developers ssh access to my linux box. Or can I set up their file permission so they can read only their project directory? UPDATE the who...

Rails 405 Method not allowed

I have a select box and on every change I am going back to my controller and fetching some data. This data is then loaded into a div. jQuery: $('#groups').change(function() { $('#emails').load('/notifications/get', {value: $(this).val()}); }); Controller: class NotificationsController < ApplicationController def...

perform a render from an application controller method

I need to do API version checks and so I've implemented a check in my controller method like: if request.header["api_version"] != 1 respond_to do |format| format.json {render :json => expiredMessage} end return end Works fine, I'm returning in the control statement so Rails doesn't complain about double render. I tried to DR...

Which MongoDB DSL should I learn?

Im using MongoDB and Ruby. I have noticed there are different DSL:s. The Javascript DSL used with the MongoDB client (mongo): show dbs use my_db db.person.find({first_name: "Syd"}) The Ruby DSL used with the Ruby driver for MongoDB: connection = Mongo::Connection.new connection.database_names.each { |name| puts name } connection.da...

How do I make a method available to both my controller and model in Rails?

I have a private method in my Rails app to connect to Amazon S3, execute a passed block of code, then close the connection to S3. It looks like so; def S3 AWS::S3::Base.establish_connection!( :access_key_id => 'Not telling', :secret_access_key => 'Really not telling' ) data = yield AWS::S3::Base.disconnect data end...

.collect on a belongs_to raising NoMethodError: undefined method `add' for nil:NilClass

Setup: Rails 3 RC2, Ruby 1.9.2 p0 (also tried on Rails 3 beta 4, Ruby 1.8.7 p174) I have quite a basic shopping cart setup: Order has_many :order_items Order has_many :products, :through => :order_items, :dependent => :restrict Product has_many :order_items Product has_many :orders, :through => :order_items, :dependent => :restrict O...

Creating an overlay popup

I want to create an in-window pop up that darkens the entire window with a semi-transparent black overlay and there is a popup in the middle that warns the user about something. I have seen something like this on att web site http://www.att.com/wireless/iphone/?wtSlotClick=1-003G93!CIWM01-3-1&amp;rel=nofollow and if you click on the o...

Ruby on Rails HTTP Basic Authentication

I am just starting to learn Ruby on Rails and have a newbie question that I have so far been unable to find the answer for. I have a small app that uses HTTP basic authentication and I have design elements in my view that I only want to display if the request is authenticated. How can I access this information? ...

Where does a rails (3) application define what is supposed to happen in activesupport-3.0.0.rc/lib/active_support/testing/setup_and_teardown.rb?

I generated a model file but then chose to let it single table inherit from another model. I had to run no migration, because the columns all were already there. Now whenever I want to run tests, I get complaints that the table for the model does not exist. So I have Product < Article < ActiveRecord::Base, product has no own table (doe...

get first value in hash within hash

Hello, Is there a simple way, instead of looping my entire array to fetch the first value of every inner array. so in essence I have the following; array = [['test', 'test2'...], ['test' ....]] so I want to grab array[#][0] and store the unqiue values. EDIT Is there a similar way to use the transpose method for arrays with Hash? ...

Understanding the basics of JSONP and Rails.

I'm having a tough time finding some basic information on the accepted way to do JSONP with my app... Let me explain, say I have an app (App A) that provides a response in json, how can I call that script using jQuery from a different site, and load that JSON data? I'm pretty sure I can just link to a JS file on app A and use that to lo...

Saving RAM on Shared Hosting with persistent process web service (e.g. Ruby on Rails, Turbogears, etc.)

I use Turbogears on my shared hosting for one-off applications, but I don't need these applications active all the time. Is there a way to start the service when I request it, and then kill the process when it's idle? For example, Turbogears will have a persistent process: "paster serve production.ini" that I would like killed if there...

Help with Rails ActiveRecord managing queries

I have 3 models. Users, Groups, Employees all of the three have many to many. user has many groups groups have many users groups have many employees employees have many groups So I've created two new models: Departments (handles many to many between Users and Groups) Employments (handles many to many between Groups and Employees)...

rails: validation without model

I have this form that allows user to send a message to an email and I want to put validation on it. I do not have a model for this, only controller. How should I do this in rails? Should I do it on the controller? I also want to flash the errors to the user. If you have a better way of doing this, please let me know. THank you. ...

many-to-many polymorphic

I hope this is a simple problem for someone because I am going round and round in circles I have an Author who can author/compose or co-author, either Songs and or Tunes. A Song constitutes the lyrics, title etc. The Tune is the score and mp3 url. I have tried the following without success class Author < ActiveRecord::Base has_many ...

Store front-end features in Rails?

In the public folder we have stylesheets, javascripts and images. I want to add a front-end feature that has it's own css, js and images, but according to this hierarchy i have to store them like this: stylesheets/calendar/main.css javascripts/calendar/cal.js javascripts/calendar/cal2.js images/calendar/front.jpg images/calendar/button...

Javascript condition based on Rails variable

I want to set a global constant (in Rails) and then depending on that I want to put a condition in a JavaScript file (which is included in every page of my app). I also have some Rails dependent code based on this variable. What is the best way to do this ? ...

Could paperclip handle non-image files?

I am using Ruby on Rails 2.3.5 I want to let the user upload files, not only images, but also music files or just txt documents. Could I use paperclip for this purpose (I will store those files in Amazon S3)? Is there any special things I have to note about? Or if the paperclip gem could not handle them, what could I use? ...

how to edit album/photo description in facebook??

i create app based ruby on rails i'm using fb_graph gem wheter possible to edit message in album or photo?? how? thx ...

Application Testing with Rails

Hi, This is more of a general question and some sort of best practice discussion. How would one test a Rails application? There are mantras like BDD and TDD and frameworks like RSpec and Cucumber but how much is enough and what is the best way to go? Is it enough to use Cucumber as integration tests? Are you guys writing additional ...