ruby-on-rails

How to get URL parameters in Rails?

When a POST request is processed, params[:id] returns the value of "id" stored in the form that was posted. However I want to get the value stored in the url (query string). def some_action id = params[:id] # Gets id from here: /some_action?id=[VALUE] only when request.post? is false if request.post? # Do some stuff, can't get th...

Rails ActionMailer TSL plugin - Sender email problem

Hi. I use ActionMailer with the action_mailer_optional_tls plugin to send mails via Gmail. Here is my setup: class InstantMailer < ActionMailer::Base layout "email" def support(ticket) @recipients = "[email protected]" @from = ticket.email #this is the user's email @subject = "[#{ticket.category}] #{tic...

Scaffolding in Rails while defining nullable fields and foreign keys

I'm just figuring out my way around rails but I need a little help with the rails generate scaffold command. Here's the command that I'd like to use rails generate scaffold Expense user:??? name:string description:text I'd like the description field to be nullable and the users field to be linked to another Model — in this case I'd l...

Ruby on Rails HABTM Multiple Dropdowns with AJAX

I have a typical HABTM relationship between members (actual members of our organization, not all have online accounts) and users (online accounts). I have an edit users page for site administrators where multiple members can be assigned to users. There are too many members to reasonably use checkboxes or a multi-select dropdown. I have ...

Adding javascript handlers to remote form object after injection with RJS

I have a page form, where i want the user to add nested forms by clicking on a remote link ('add photo', f. ex). Upon clicking the button I inject the nested forms with RJS. The injected forms are remote forms, but after injection the forms have no javascript events attached so they just submit with http to the controller of the nested o...

How to clear the password fill on registration/sign up error with authlogic?

I'm using Ruby 1.8.7, Rails 2.3.8, and using Authlogic 2.1.6 for registration, login, logout. In fact, those three things are nearly all I've done! During registration, if the user has errors in their registration information, I want the password and password_confirmation fields to be empty when the view is redrawn. I assumed one could...

How can I override a method in a ConnectionAdapter class in Rails 3 for use in a rake task?

In order to override the table_exists? method in the Rails PostgreSQL adapter I have tried the following in an initializer file: ActiveRecord::ConnectionAdapters::PostgreSQLAdapter.class_eval do def table_exists?(name) raise 'got here' end end This will raise the the following error: uninitialized constant ActiveRecord::Conne...

Lightweight Ruby MVC web development framework which plays nicely with ExtJS

I'm looking for a lightweight MVC Ruby framework for developing an ExtJS application. I started with Rails 3.0, but I feel that I'm struggling with the ActionPack (which I don't really need). Since all the UI (view) is done in ExtJS, I don't need any rendering support. What I do need is a routing infrastructure (for REST), session suppo...

Rails 2.3.10, Paperclip and s3 dead slow and would like to Ajax

I'm using Paperclip and s3 to upload a simple Image file on article. I've browse all these tutorials explaining on how to actually make a delayed job, for the images, but i feel that they're too old and perhaps there's an easier way to accomplish this. My question is, what's the "rails" (quick and easy) of accomplishing an flash/ajax upl...

Rails 3 Override Destroy without Canceling callbacks, and triggering a ROLLBACK

My desired behavior is that when destroy is called on an instance, that instance will not actually be destroyed, but it will just be marked as having been destroyed. This needs to percolate up for any model associations. In the models that I don't want to actually destroy, but just mark them as deleted I have a deactivated field. From...

Rails3 ActiveRecords displaying column with wrong datatype?

I am not sure how to title this question, its something rather weird. Well, here is the thing, I've created a model called UserProfiles for which the migration file looks like this: class CreateUserProfiles < ActiveRecord::Migration def self.up create_table :user_profiles, :primary_key => :id, :options => "auto_increment = 1" d...

When rendering js.erb file, it renders layout with the javascript, is it a bug?

A workaround that I found was to explicitly state in controller render :action => :some_action, :layout => false otherwise JavaScript fails to work Anyone found this problem or maybe something is wrong with my configuration... ...

What does Rails 3 session_store domain :all really do?

Updated question to make it more clear I understand that you can set the domain of your session_store to share sessions between subdomains like this: Rails.application.config.session_store :cookie_store, :key => '_my_key', :domain => "mydomain.com" in Rails 3, what does the setting :domain => :all do? It can't let you share sessions ac...

Getting the parent resource from the URL

I've got two objects (@stacks and @stories) with has_many relationships (through @anthologies). Stories can be viewed individually (/stories/1/) or as a collection in a Stack (/stacks/1/stories/1/). map.resources :stories map.resources :anthologies map.resources :stacks, :has_many => :stories do |stack| stack.resources :stories end ...

Server setup for basic forum-style app on iPhone?

I'm not really a server-side person – I generally do iPhone apps, though I've hacked together a few Wordpress sites. I'm curious as to what web technologies people would use for the back-end of an iPhone app whose front end presents as a basic forum. In other words, people can create new threads, and respond to them - with plain text on...

Will_Paginate --- Set the Starting record ?

Hello! I have a photo_album which has several photos, IDs: 4,9,10,11,31 -- all for photo_album:3 I have the following for my DEF SHOW in my Photos controller: @photo = @photoalbum.photos.order("created_at ASC").paginate :page => params[:page], :per_page => 1 Problem is, if the URL is: /photo_albums/3/photos/10 The code above starts ...

How to make custom authorization rools in RoR3

There are a few very good authorization gems, like cancan and declarative_authorization. But here's a problem: authorization rules are seperated in class, but i need to place them in table or maybe some yaml config file to change them in admin panel eventually. Perfectly, if i can either change permissons for user groups and for individu...

Writing an API for Rails OAuth provider

I'm having trouble figuring out how to write an REST API using OAuth authentication. The actual authentication part is working fine, but I'm not sure how to access the OAuth token in order to find the associated user. Here is the (barebones) code that I am currently working with in my controller: class UsersController < ApplicationCont...

Select prompt option disappears when validation fails in Rails

Let me preface by saying I'm a noob to Rails and StackOverflow so please go easy on me. I'm using Rails 2.3.8 with sqlite3 on my dev box. I have created a select pulldown in a form using the following: <%= select( "communication", "gig_id", { "Add New Gig" => "new"}, {:prompt => "-- Select Gig --"}, :onchange => "toggle(this, 'gigInfo...

Problem with Active Record Querying

Hi, I am building a little application in Rails and what I am trying to do now is authenticate a user. So I got this method in the controller class: def login if @user = User.authenticate(params[:txt_login], params[:txt_password]) session[:current_user_id] = @user.id redirect_to root_url end end He...