ruby-on-rails-3.1

Multistep form with ActiveAdmin?

我与影子孤独终老i 提交于 2019-12-05 02:50:59
问题 Is it possible to create a multistep form with ActiveAdmin? If not, is it possible to just add another page that it redirects to after submitting the form (one that is not the default index, show or form pages)? 回答1: I've been fretting with this issue myself. I found that you can add your own pages using collection actions in your ActiveAdmin file. Say your model is called MyModel, you would add this to your ActiveAdmin my_model.rb file. # GET /admin/my_model/page1 collection_action :page1,

Is it possible to have a dynamic storage path with carrierwave?

陌路散爱 提交于 2019-12-05 02:50:38
问题 I am starting with carrierwave for file uploads and have been quite happy with it so far. My files are stored on amazon s3 which was fairly easy and it works reliably. Now I have a model named pictures and an uploader name MainUploader . I need a special dynamic path to save those files to when uploaded. I am also using devise and I have the current_user I can access from my views and controller but not from the carrierwave uploader. I need the path of the file to be something like uploads/#

Heroku cedar, Rails 3.1rc6, subdomain routing

纵然是瞬间 提交于 2019-12-05 02:50:22
问题 Locally, on Unicorn, my subdomain setup works fine. I've followed the heroku subdomain docs to the letter, and also the subdomains Railscast. subdomain.lvh.me:3000 points to the right place, and lvh.me:3000 points correctly to the root defined in routes.rb: root :to => "pages#home" However, in my new staging deployment on Heroku's Cedar stack, again using Unicorn, whilst subdomain.mydomain.co.uk points to the right place, mydomain.co.uk doesn't. Instead of going to pages#home as per the

Rails 3.1 - How do I organize multiple index actions for the same model?

。_饼干妹妹 提交于 2019-12-05 02:40:58
问题 I have a User model that has_many projects. The Project model belongs_to the User model. I am currently using the projects_controller.rb index action to display all of the projects that have been created across all users (Project.all). On a separate page, I would also like a way to display all of the projects that belong to a specific user (i.e. go to page and be able to see all of the projects that belong to a given user). I am having difficulty figuring out which controller/action/view to

How do you handle single table inheritance in SimpleForm so a single helper handles all models?

余生颓废 提交于 2019-12-05 02:15:23
问题 We have a model "EventSession" which has several subtypes via STI, including "NetworkingEventSession" and "DiningEventSession"... we want to be able to handle all of them from one controller and one view in some cases, but simple form is looking at the objects when iterating through in simple_form_for @session and trying to use the networking_event_session_path helper, which we don't currently have defined, instead of the regular event_session_helper path, which would work fine and is what we

Rails 3.1 - find using count and select as

你说的曾经没有我的故事 提交于 2019-12-05 02:13:06
I am trying to do the following sql statement in rails: SELECT COUNT(downloads.title) AS total, downloads.title FROM `downloads` WHERE `downloads`.`member_id` = 60 Group by `downloads`.`title` I wrote this in rails like this: Download.where(:member_id => id).select("COUNT(downloads.title) AS total, downloads.title").group(:title) If I run the query straight from the sql server the sql executes correctly but if I run the activerecord version I only get the title back. I thought this might be because of attr_accessible but this doesnt seem to have made a difference. any ideas ? Have you tried to

Devise ..After first login should ask for change password

妖精的绣舞 提交于 2019-12-05 02:10:37
问题 I am using devise as authentication in my application. I need to implement feature in devise. After first login user should ask to change password. I tried through model after_create :update_pass_change def update_pass_change self.pass_change = true self.save end 回答1: Checking current_user.sign_in_count is way to judge first login. You'll do something like this. class ApplicationController < ActionController::Base def after_sign_in_path_for(resource) if current_user.sign_in_count == 1 edit

How to use Sprockets 2 with Rails 3.0.x (how to use precompiled assets)

天涯浪子 提交于 2019-12-05 02:03:51
问题 I'm trying to replicate the basics of the asset pipeline introduced in rails 3.1 in my rails 3.0 app . So far, I've got something like this: https://gist.github.com/1112393. It works great: I have my assets in app/assets/, lib/assets, vendor/assets... They're all served at /assets I can use everything sprockets 2 offers etc... The thing is, I don't want the rails app to serve static assets. The server should do it. That's why you can precompile assets in rails 3.1, if I understood correctly.

What is the best place to store static assets (files) in rails 3.1 ( pdf forms, xls files, etc)

孤街浪徒 提交于 2019-12-05 01:39:16
I have a bunch of static assets ( not jpg, css, & js) - rather files like pdf forms, xls that I need to serve to users. They rarely change. Before I used to store them in public folder, but with the introduction of the assets pipeline in rails 3.1 what is the best place to store files like that now now? thanks Actually I just tested it by creating a folder in app/assets/files and sticking my xls files in there, and rake assets:precompile task just picked it up. Also this needs to be added for Rails < 3.1: # Enable the asset pipeline config.assets.enabled = true config.assets.paths << "#{Rails

RubyGems error after updating system

谁说胖子不能爱 提交于 2019-12-05 01:22:05
When trying to launch the rails console after updating my ruby setup using 'sudo gem update --system', I then try execute the rails console by issuing rails c I get this error: Users/myusername/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find json (~> 1.4) amongst [Ascii85-1.0.1, abstract-1.0.0, actionmailer-3.1.1, actionmailer-3.1.0, actionmailer-3.0.9, actionmailer-3.0.5, actionmailer-3.0.3, actionpack-3.1.1, actionpack-3.1.0, actionpack-3.0.9, actionpack-3.0.5, actionpack-3.0.3, activemodel-3.1.1, activemodel-3.1.0, activemodel-3