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...
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...
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...
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 ...
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...
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...
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...
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...
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...
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...
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...
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...
...
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...
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 ...
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...
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 ...
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...
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...
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...
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...