返回从模型到视图的路径

时间:2013-04-14 04:59:32

标签: ruby-on-rails

使用Rails 3.2。我有以下内容:

# user.rb
class User < ActiveRecord::Base
  def user_website
    if self.website.blank?
      main_user_url(self.login)
    else
      self.website
    end
  end
end

# users/show.html.erb
<%= @user.user_website %>

但它会返回此错误:

undefined method `main_user_url' for #<User:0x007f9094552978>

如何正确传递网址?以前我把它放在users_helper.rb中,但是想把它放在模型中会更合适。

0 个答案:

没有答案
相关问题