ruby-on-rails-3

Multi step form with image uploader

十年热恋 提交于 2021-02-07 02:58:56
问题 I want to build 3 step user registration with avatar uploading on 2nd step. So i follow Ryan Bates's guide http://railscasts.com/episodes/217-multistep-forms . I'm using CarrierWave gem to handle uploads. But it seems like i can't store uploaded file info in user session (i'm getting can't dump File error). I use following technique in controller if params[:user][:img_path] @uploader = FirmImgUploader.new @uploader.store!(params[:user][:img_path]) session[:img] = @uploader params[:user]

delayed_job update query is running infinitely

ぃ、小莉子 提交于 2021-02-06 15:31:46
问题 I am using delayed_job and delayed_job_active_record for back ground job execution in my rails application. We are using queue based delayed_job. For starting the delayed I am using the following command. RAILS_ENV=staging script/delayed_job -i=1 --queue=queue_name start The problem is below query is firing infinitely. SQL (0.4ms) UPDATE `delayed_jobs` SET `locked_at` = '2013-04-16 09:27:23', `locked_by` = 'delayed_job.=2 host:ip-10-204-210-77 pid:2168' WHERE `delayed_jobs`.`queue` IN ('queue

delayed_job update query is running infinitely

空扰寡人 提交于 2021-02-06 15:30:19
问题 I am using delayed_job and delayed_job_active_record for back ground job execution in my rails application. We are using queue based delayed_job. For starting the delayed I am using the following command. RAILS_ENV=staging script/delayed_job -i=1 --queue=queue_name start The problem is below query is firing infinitely. SQL (0.4ms) UPDATE `delayed_jobs` SET `locked_at` = '2013-04-16 09:27:23', `locked_by` = 'delayed_job.=2 host:ip-10-204-210-77 pid:2168' WHERE `delayed_jobs`.`queue` IN ('queue

delayed_job update query is running infinitely

烂漫一生 提交于 2021-02-06 15:29:25
问题 I am using delayed_job and delayed_job_active_record for back ground job execution in my rails application. We are using queue based delayed_job. For starting the delayed I am using the following command. RAILS_ENV=staging script/delayed_job -i=1 --queue=queue_name start The problem is below query is firing infinitely. SQL (0.4ms) UPDATE `delayed_jobs` SET `locked_at` = '2013-04-16 09:27:23', `locked_by` = 'delayed_job.=2 host:ip-10-204-210-77 pid:2168' WHERE `delayed_jobs`.`queue` IN ('queue

Labeled fixtures for associations in Rails 3 broken

孤者浪人 提交于 2021-02-06 10:19:45
问题 After upgrading to Rails 3, fixtures that refer to other labelled fixtures (for relationships) stop working. Instead of finding the actual fixture with that name, the fixture label is interpreted as a string. Example: # Dog.yml sparky: name: Sparky owner: john # Person.yml john: name: John Where Dog "belongs to" person. The error message is: SQLite3::SQLException: table dogs has no column named 'owner' 回答1: Try # Dog.yml sparky: name: Sparky owner: john (Person) # Person.yml john: name: John

Get time from DateTime Variable in Ruby

a 夏天 提交于 2021-02-06 09:47:09
问题 I am working in ruby, i ahave an object containing today's datetime from database. I only want time truncating the date. How can i get that? 回答1: Try DateTime#strftime. DateTime.now.strftime("%H:%M") # => "12:17" 回答2: #!/usr/bin/ruby -w time1 = Time.now puts "Current Time : " + time1.hour + ":" + time1.min + ":" + time1.sec Taken from & credit to - This TutorialsPoint Post. 回答3: If you use it really often you can use the gem time_splitter to help you set some accessors of date, time, hour and

Get time from DateTime Variable in Ruby

只谈情不闲聊 提交于 2021-02-06 09:46:40
问题 I am working in ruby, i ahave an object containing today's datetime from database. I only want time truncating the date. How can i get that? 回答1: Try DateTime#strftime. DateTime.now.strftime("%H:%M") # => "12:17" 回答2: #!/usr/bin/ruby -w time1 = Time.now puts "Current Time : " + time1.hour + ":" + time1.min + ":" + time1.sec Taken from & credit to - This TutorialsPoint Post. 回答3: If you use it really often you can use the gem time_splitter to help you set some accessors of date, time, hour and

Rendering markdown text in Rails 3

喜欢而已 提交于 2021-02-06 09:38:32
问题 I want to convert markdown to html. In my views I have markdown(some_text_variable) but I get the error undefined method markdown . I added require 'BlueCoth' to enviroment.rb and I installed the BlueCloth gem. Can anybody help me? 回答1: In your Gemfile: gem 'bluecloth' and don't forget to run bundle install when you need to convert markdown to html, simply use: markdown = BlueCloth.new(some_text_variable).to_html You can use it in a view: <%= markdown.html_safe %> 回答2: You can use RDiscount

Understanding Rails ActiveRecord “single model” self joins

让人想犯罪 __ 提交于 2021-02-05 13:28:14
问题 I'm having a hard time understanding how to implement a single model self-join in Rails. The Guide to ActiveRecord Associations section 2.10 briefly explains Self-Joins but doesn't offer enough information, and every example or post about this such references the Friendly Friend Railcast example that isn't a single model self join, as described in the Rails Guide section 2.10. The idea is a model that has_many and belongs_to itself, without needing a separate table for the relationship. The

Understanding Rails ActiveRecord “single model” self joins

烈酒焚心 提交于 2021-02-05 13:26:38
问题 I'm having a hard time understanding how to implement a single model self-join in Rails. The Guide to ActiveRecord Associations section 2.10 briefly explains Self-Joins but doesn't offer enough information, and every example or post about this such references the Friendly Friend Railcast example that isn't a single model self join, as described in the Rails Guide section 2.10. The idea is a model that has_many and belongs_to itself, without needing a separate table for the relationship. The