ruby-on-rails-3

rails 3 - fcgi_handler and dispatcher missing

我与影子孤独终老i 提交于 2020-01-06 06:09:29
问题 Im trying to update a 1&1 server to run rails 3 with apache and fastcgi. Has anyone done this yet? I the dispatch.fcgi file I have: require 'fcgi_handler' but apparently rails 3 does not have this file any more. 回答1: You have the rack gem which has fcgi handler 来源: https://stackoverflow.com/questions/3522423/rails-3-fcgi-handler-and-dispatcher-missing

Getting Format in Mailer View in Rails

断了今生、忘了曾经 提交于 2020-01-06 06:07:07
问题 In my Rails app, I use a method in my Mailer views for creating a link that takes a format param based on whether it's in html or text format. mailer_link_to( url, link_text, format ) Depending on the format, it either creates an anchor <a> tag for html or just shows the url for text. So for each Mailer method, I have two views: myemail.html.erb myemail.text.erb In myemail.html.erb , I use mailer_link_to( "http://ntwrkapp.com", "ntwrk", "html" ) . In myemail.text.erb I use mailer_link_to(

Passing IDs through a new Form

我怕爱的太早我们不能终老 提交于 2020-01-06 05:50:12
问题 This question is about a different approach I'm trying to the one asked here: Passing IDs through a new Form I have a group#view page , that is accessed by a Person . In this page, the Person can see the members of the group via methods I developed. The problem is that I need to create the model Honors using the Id from the group , the id from the person accessing the page, and the id from a member of this group . In my Honors controller I have: def create @person = Person.find(current_person

RoR: how can I search only microposts with a certain attribute?

廉价感情. 提交于 2020-01-06 05:42:12
问题 Right now in app/views/microposts/home.html.erb I have.. <% form_tag purchases_path, :method => 'get', :id => "products_search" do %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %> </p> <% end %> <% form_tag sales_path, :method => 'get', :id => "sales_search" do %> <p> <%= text_field_tag :search, params[:search] %> <%= submit_tag "Search", :name => nil %> </p> <% end %> and then in micropost.rb I have scope :purchases, where(:kind => "purchase")

Array sort by date and month only (ignore year)

ぃ、小莉子 提交于 2020-01-06 05:09:53
问题 I have following festival array: id = 1, Start_date = 2011-11-01 , End_date = 2016-12-31 [[1, 2011-11-01 , 2016-12-31], [2, 2011-11-28 , 2016-12-31], [3, 2011-10-01 , 2015-12-31], [4, 2011-11-28 , 2021-12-31], [5, 2010-11-15 , 2016-12-31], [6, 2011-07-01 , 2017-12-31], [7, 2012-02-01 , 2013-02-19], [8, 2011-03-21 , 2015-04-30], [9, 2012-03-01 , 2016-03-20]] I need to sort this by start_date start from current date but ignore year here (use only month and day). Actually these are festival's

Array sort by date and month only (ignore year)

╄→尐↘猪︶ㄣ 提交于 2020-01-06 05:09:26
问题 I have following festival array: id = 1, Start_date = 2011-11-01 , End_date = 2016-12-31 [[1, 2011-11-01 , 2016-12-31], [2, 2011-11-28 , 2016-12-31], [3, 2011-10-01 , 2015-12-31], [4, 2011-11-28 , 2021-12-31], [5, 2010-11-15 , 2016-12-31], [6, 2011-07-01 , 2017-12-31], [7, 2012-02-01 , 2013-02-19], [8, 2011-03-21 , 2015-04-30], [9, 2012-03-01 , 2016-03-20]] I need to sort this by start_date start from current date but ignore year here (use only month and day). Actually these are festival's

Cron job in ruby on rails not work

坚强是说给别人听的谎言 提交于 2020-01-06 04:47:07
问题 I followed the railscast http://railscasts.com/episodes/164-cron-in-ruby but I cant seem to make it worked. I have schedule.rb in my config. I wished to refresh my Database.count everyday in my homepage. I cannot find the deploy.rb in my folder. Where is it? For testing purpose, I changed it to every 2 seconds. [schedule.rb] every '2 * * * *' do rake "pages_controller:home" end [pages_controller.rb] class PagesController < ApplicationController def home @title = "Home" @companies = Company

Twitter::Error::Forbidden - Unable to verify your credentials

梦想与她 提交于 2020-01-06 04:35:11
问题 I'm using devise + omniauth and I can connect to twitter api correctly. But when I try to use twitter gem, I have the following error in console : "Twitter::Error::Forbidden - Unable to verify your credentials" I have installed the gem and created an initializer at config/initializers/twitter.rb Twitter.configure do |config| config.consumer_key = PKe41... config.consumer_secret = qETY..... end And I'm trying into a controller : def twitter @twitter_home_timeline = Twitter.home_timeline end

DelayedJob: “Job failed to load: uninitialized constant Syck::Syck”

梦想与她 提交于 2020-01-06 04:24:46
问题 I am using Ruby on Rails 3.1 and the DelayedJob gem. I have a Contact Us form through which people can contact me. When I submit that I get the following error `last_error` = '{Job failed to load: uninitialized constant Syck::Syck. Handler: \"--- !ruby/struct:Delayed::PerformableMailer ... However, I have also others forms that send e-mails (eg: Sign Up and Sign In users) and those work as expected. The only problem seems to occur with the Contact Us form. I read others related problem posts

undefined method `microposts'

为君一笑 提交于 2020-01-06 03:50:15
问题 It worked before but why it isn't now? I was trying to to create a post by only the signIn user.Or is it my routing problems? My routing is resources :users do resources :microposts end microposts controller def create @micropost = current_user.microposts.build(params[:micropost]) if @micropost.save flash[:success] = "Post created!" redirect_to @micropost else render 'new' end end new.html.erb <%= form_for @micropost do |f| %> <%= render 'shared/error_messages', :object => f.object %> <%= f