我在我的rails应用程序上设置了活动管理员.我运行生成器来创建用户资源但是当我点击管理仪表板上的用户链接时,我得到:
NoMethodError in Admin/users#index
Showing /Users/nelsonkeating/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/gems/1.9.1/gems/activeadmin-0.4.4/app/views/active_admin/resource/index.html.arb where line #1 raised:
undefined method `city_id_contains' for #<MetaSearch::Searches::User:0x007fde92d69840>
Extracted source (around line #1):
1: render renderer_for(:index)
Run Code Online (Sandbox Code Playgroud)
我不知道是什么产生了这个或错误来自哪里..任何想法?谢谢!(如果您需要查看任何其他文件,请告诉我)
楷模:
user.rb
class User < ActiveRecord::Base
rolify
devise :database_authenticatable, :registerable, :confirmable,
:recoverable, :rememberable, :trackable, :validatable
attr_accessible :province_id, :city_id
belongs_to :province
belongs_to :city
Run Code Online (Sandbox Code Playgroud)
province.rb
class Province < ActiveRecord::Base
has_many :cities
has_many :users
end
Run Code Online (Sandbox Code Playgroud)
city.rb
class City < ActiveRecord::Base
belongs_to :province
has_many :users
end
Run Code Online (Sandbox Code Playgroud)
schema.rb
create_table "users", :force => true do |t|
t.string "email", :default => "", :null …
Run Code Online (Sandbox Code Playgroud) ruby ruby-on-rails ruby-on-rails-3 activeadmin ruby-on-rails-3.2
无论我做什么,我的朋友的嵌套表单字段都不会显示..我相信,accept_nested_attributes设置是否正确?
views/user_steps/show.html.erb
<%= simple_form_for @user do |f| %>
<%= f.input :city %>
<%= f.input :address %>
<%= f.input :zipcode %>
<%= f.input :date_of_birth %>
<%= f.input :gender, :collection => ['male','female'] %>
<%= f.association :interests, :as => :check_boxes, :label => false %>
<%= f.association :holidays, :as => :check_boxes, :label => false %>
<%= f.simple_fields_for :friends do |friend_f| %>
<%= friend_f.input :name %>
<%= friend_f.input :dob %>
<%= friend_f.input :gender %>
<% end %>
<%= f.button :submit %>
<%end%>
class UserStepsController < …
Run Code Online (Sandbox Code Playgroud) ruby-on-rails associations nested-attributes ruby-on-rails-3 simple-form
与此问题相关的模型:用户,朋友,兴趣,person_interest.Person_interest是多态的,可以存储属于用户或朋友的兴趣.
兴趣预先填充大约.30个利益.当用户注册时,他们被要求选择自己的兴趣,然后在表单中输入他们的朋友姓名,选择该人的兴趣.
试图实现这一目标 <%= friend_f.input :interests, :as => :check_boxes, :label => false %>
但得到以下错误:
NoMethodError in User_steps#show
Showing /Users/nelsonkeating/Desktop/ReminDeal/app/views/user_steps/show.html.erb where line #30 raised:
undefined method `to_i' for []:ActiveRecord::Relation
Extracted source (around line #30):
27: :end_year => Date.today.year - 12,
28: :order => [:month, :day, :year ] %>
29: <%= friend_f.input :gender, :collection => ['male','female'] %>
30: <%= friend_f.input :interests, :as => :check_boxes, :label => false %>
31: <%end%>
32:
33:
Rails.root: /Users/nelsonkeating/Desktop/ReminDeal
Application Trace | Framework Trace | Full Trace …
Run Code Online (Sandbox Code Playgroud) 我的rails应用程序中有一个联系表单.现在它只是重定向到主页,无论如何.如果用户已登录,我想重定向到user_path,如果不是,我想重定向到主页..我该怎么做?
*使用设计
contact_controller
def create
@message = Message.new(params[:message])
if @message.valid?
NotificationsMailer.new_message(@message).deliver
redirect_to(user_path, :notice => "Message was successfully sent.")
else
flash.now.alert = "Please fill all fields."
render :new
end
end
end
Run Code Online (Sandbox Code Playgroud) 我怎样才能在wordpress索引页面中显示特定类别?以下是我的主题代码......
此外,当查看我的类别的URL(我通常如何获取ID)时,它似乎是一种奇怪的格式..
<?php query_posts( array ( 'Event_News' => 'event-news' ) ); ?>
<?php if (have_posts()) : ?>
<ul class="posts">
Run Code Online (Sandbox Code Playgroud)
<li id="post-<?php the_ID(); ?>">
<?php
get_the_image( array( 'size' => 'loop-main', 'width' => 160, 'height' => 120, 'before' => '<div class="cover">', 'after' => '</div>' ) );
?>
<div class="postcontent">
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="postmetadata">
<ul>
<?php if (option::get('display_date') == 'on') { ?><li class="calendar"><time datetime="<?php the_time("Y-m-d"); ?>" pubdate><?php the_time("j F Y"); ?></time></li><?php } ?>
<?php if …
Run Code Online (Sandbox Code Playgroud) 我有一个interests
只有:name
属性的表.
我正试图播种(通过seed.rb
)以下数组,以便它们都以我的形式显示(复选框)......我该怎么做?
有没有比存储它更好的方法seed.rb
?
[ "Adventure Sports", "Arts and Crafts", "Beauty/Hair",
"Books", "Dining Out", "Fine Art", "Fine Jewelry",
"Gardening", "Golf" ]
Run Code Online (Sandbox Code Playgroud) 每次重置和播种数据库时,它都会清除Active Admin的标准admin@example.com登录信息.
在我的种子文件中,我将用户设置为具有角色:admin但此登录仅适用于应用程序的前端而不适用于后端活动管理员登录.我该如何解决这个问题?谢谢!
注意*我使用Devise + cancan + rolify
Seeds.rb
user2 = User.create! :name => 'Second User', :email => 'user2@example.com', :password => 'please', :password_confirmation => 'please', :confirmed_at => Time.now.utc
puts 'New user created: ' << user2.name
user.add_role :admin
Run Code Online (Sandbox Code Playgroud) 我似乎无法将我的背景图像垂直拉伸(使用CSS)并且无法获得它.如果不使用jquery插件,最好的方法是什么?
目前有
div#whitewrap {position:fixed; top:0; left:0; width:100%; height:100%;}
Run Code Online (Sandbox Code Playgroud) 我正在尝试动画(从左到右)带有页面加载转换延迟的下划线.我知道如何让它在悬停时工作,但不是在加载时.尝试这样的东西,但不知道为什么它不会工作.
.under {
position: relative;
text-decoration: none;
display: inline-block;
}
.under::after {
content: "";
position: absolute;
width: 100%;
height: 2px;
bottom: 0;
left: 0;
background-color: #000;
-webkit-transition-delay: 2s;
transition-delay: 2s;
-webkit-transition: all 0.3s ease-in-out 0s;
transition: all 0.3s ease-in-out 0s;
}
Run Code Online (Sandbox Code Playgroud) 收到以下错误:
SyntaxError in FriendsController#index
/Users/nelsonkeating/Desktop/ReminDeal/app/controllers/friends_controller.rb:32: syntax error, unexpected keyword_end, expecting ')'
/Users/nelsonkeating/Desktop/ReminDeal/app/controllers/friends_controller.rb:58: syntax error, unexpected $end, expecting keyword_end
Rails.root: /Users/nelsonkeating/Desktop/ReminDeal
Application Trace | Framework Trace | Full Trace
activesupport (3.2.3) lib/active_support/dependencies.rb:469:in `load'
activesupport (3.2.3) lib/active_support/dependencies.rb:469:in `block in load_file'
activesupport (3.2.3) lib/active_support/dependencies.rb:639:in `new_constants_in'
activesupport (3.2.3) lib/active_support/dependencies.rb:468:in `load_file'
activesupport (3.2.3) lib/active_support/dependencies.rb:353:in `require_or_load'
activesupport (3.2.3) lib/active_support/dependencies.rb:502:in `load_missing_constant'
activesupport (3.2.3) lib/active_support/dependencies.rb:192:in `block in const_missing'
activesupport (3.2.3) lib/active_support/dependencies.rb:190:in `each'
activesupport (3.2.3) lib/active_support/dependencies.rb:190:in `const_missing'
activesupport (3.2.3) lib/active_support/inflector/methods.rb:229:in `block in constantize'
activesupport (3.2.3) lib/active_support/inflector/methods.rb:228:in `each'
activesupport (3.2.3) …
Run Code Online (Sandbox Code Playgroud) activeadmin ×2
activerecord ×2
css ×2
css3 ×2
ruby ×2
simple-form ×2
associations ×1
php ×1
wordpress ×1