ruby-on-rails-3

How to start rails server?

别说谁变了你拦得住时间么 提交于 2019-12-30 03:45:06
问题 I am developing rails 2.3.2 application. When I type the command " rails script/server " I got the following output instead of server starting why? rails script/server Usage: rails new APP_PATH [options] Options: -J, [--skip-javascript] # Skip JavaScript files [--dev] # Setup the application with Gemfile pointing to your Rails checkout [--edge] # Setup the application with Gemfile pointing to Rails repository -G, [--skip-git] # Skip Git ignores and keeps -m, [--template=TEMPLATE] # Path to an

Rails3 + Devise : prevent password validation when updating

风格不统一 提交于 2019-12-30 03:30:07
问题 I've looking for a way to allow users to change their settings (User model) without having to change their password (they still have to enter their current password). Devise out of the box seems to allow this, but when you remove the validatable module and setup custom validations, it seems you need to work around a bit. I have setup the following validation in my user model : validates :password, length: { in: 6..128 } When signing up, user is required to specify his password (which is what

ImageMagick Install Windows

亡梦爱人 提交于 2019-12-30 03:19:05
问题 I am trying to install ImageMagick on Windows. What I did is install Windows RailsInstaller created my version and now I need to use ImageMagick but for some reason it doesn't work. I took the binary source code and install and run it from this page but didn't seem to do the trick http://www.imagemagick.org/script/binary-releases.php#windows I also try the following http://www.youtube.com/watch?v=gEWAVlNCKhg but it doesn't work For the first example In cmd all I have to do is the following

Rails 3 and Strange Accept Headers

有些话、适合烂在心里 提交于 2019-12-30 03:18:08
问题 My Rails 3 site is getting hit by crawlers with strange accept headers, trigger exceptions as like ActionView::MissingTemplate occurred in home#show Here are some of the accept headers causing issues text/* application/jxw */*;q=0.1 In these cases, this is being interpreted as the format for the request, and as such, causing the missing template error. I don't really care what I return to these crawlers, but just want to avoid the exceptions. 回答1: You could rescue from exception like this in

Create migration files in rails from existing mysql table

橙三吉。 提交于 2019-12-30 03:13:06
问题 I m developing an application in rails. I have created a table say "student" in mysql. Is there anyway to create its migration file in rails application? I have specified databse name in config/database.yml" and using others table too. But i want to create tables migration file. How can i do it? 回答1: Start by referencing your existing MySQL database in database.yml run rake db:schema:dump to generate the schema.rb file Paste the create_table methods from your schema.rb into a new migration,

Rails: Make this rake task aware that it is in the test environment

偶尔善良 提交于 2019-12-30 02:50:14
问题 I have the following rake task defined in my lib/tasks folder: namespace :db do namespace :test do task :prepare => :environment do Rake::Task["db:seed"].invoke end end end Now, what this does is seed the test DB when I run rake db:test:prepare . I do this because I have some basic records that must exist in order for the app to function, so they're not optional and can't really be mocked. Separately, I have a model that uses S3 for asset storage in development and production, but I don't

Correcting time for daylight savings in rails DateTime.parse

给你一囗甜甜゛ 提交于 2019-12-30 02:45:11
问题 Just adding to the million questions about time zone and DST issues out there. I have a form with separate date and time fields that I combine to create a DateTime like so start_time = DateTime.parse("#{parse_date(form_date)} #{form_start_time} #{Time.zone}") If I fill out my form with 21 Aug 2012 and 15:00, then these are the values that I see when I reload my form. If I then look at my start_time attribute in my model it is correctly set to Tue, 21 Aug 2012 15:00:00 EST +10:00 . The problem

Where did link_to_function disappear to in Rails 3?

瘦欲@ 提交于 2019-12-30 02:36:06
问题 I was just playing around with Rails 3 beta and noticed that link_to_function is now gone. I presume there's an alternate method of achieving the same result (onclick event?) but I was wondering if there's a more Rails-3'y way of doing it. TIA. 回答1: Rails 3 seems to have done away with Prototype Helper in favour of a less obtrusive/JS library agnostic approach. The goal is to eliminate all inline javascript generated by Rails. Prototype Helper generated pretty much all of the javascript. Now

Ruby on rails 3 link_to controller and action

别说谁变了你拦得住时间么 提交于 2019-12-30 02:33:06
问题 I know this is probably a pretty simple concept. I am trying to create a link to a controller and action. For example I have a link in my layout file to update a record when a link is clicked, so I need to be able to link to the controller and action. How would I accomplish this? 回答1: link_to "Label", :controller => :my_controller, :action => :index See url_for. 回答2: Also with CSS: <%= link_to "Purchase", { :controller => :transactions, :action => :purchase }, { class: "btn btn-primary btn-lg

Rails 3/Kaminari/JQuery - load more button: problem to display results (it loads the entire page layout and not only the partial layout)

痴心易碎 提交于 2019-12-30 02:28:11
问题 Begin with ajax and jquery combined with rails, I am trying to create a "load more" link in the bottom of my user index page. My user index page should display the 10 first users, then clicking the link it loads the next 10 users on the bottom of the user div, etc.. I use Kaminari for pagination. I started with the following code: User_controller.rb def index @users = User.page(params[:page]).per(10) end User/index.html.erb <div id="users"> <%= render :partial => @users %> </div> <%= link_to