我使用netzke
+ rails 4
+ extjs-4.2.1
遇到了一种奇怪的行为
每次第一次加载页面时都会显示div,但在刷新页面之前不会加载网格。我无法使用rails 3
+ netzke 0.8
+ extjs-4.1
重现错误。这可能是一个netzke错误吗?我使用浏览器控制台,没有显示错误。
我目前正在使用此版本的netzke:
gem "netzke-core", "~> 0.10.0.rc2"
gem "netzke-basepack", "~> 0.10.0.rc2"
和Rails 4.0.2
与extjs-4.2.1
我的application.html.erb
<!DOCTYPE html>
<html>
<head>
<title>Railroad</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= load_netzke %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="wrap">
<div id="header">
<div>
<h1>Demo</h1>
<hr/>
</div>
<div style="float: left;">
<% if I18n.locale == I18n.default_locale %>
<%= link_to "Español", :locale=>'es'%>
<% else %>
<%= link_to "English", :locale=>'en'%>
<%end%>
</div>
<div style="float: right;">
<% if user_signed_in? %>
<%= link_to (t :sign_out), destroy_user_session_path, :method => :delete %>
<% end %>
</div>
</div>
<div id="main-content">
<%= render 'layouts/messages' %>
<%= yield %>
</div>
<div id="footer">
<hr/>
</div>
</div>
</body>
</html>
我的欢迎/ index.html.erb
<h2><%= t :post_option %></h2>
<ul>
<li><%= link_to (t :post_list), posts_path%></li>
<li><%= link_to (t :post_new), new_post_path%></li>
</ul>
我的帖子/ index.html.erb
<h2>TEST</h2>
<%= netzke :posts, height: 400 %>
<br/>
<%= link_to (t :back), root_path %>
我的routes.rb
Railroad::Application.routes.draw do
devise_for :users, :controllers => {:registrations => "registrations", :omniauth_callbacks => "omniauth_callbacks"}
resources :posts do
resources :comments
end
netzke
root "welcome#index"
end
我的模特post.rb
class Post < ActiveRecord::Base
has_many :comments, dependent: :destroy
validates :title, presence: true, length: { minimum: 5 }
private
def post_params
params.require(:post).permit(:title, :text)
end
end
我的组件/ posts.rb
class Posts < Netzke::Basepack::Grid
def configure(c)
super
c.model = "Post"
c.columns = [
:title,
:text
]
c.prohibit_update = true
c.prohibit_delete = false
end
end
感谢您的帮助。
更新
问题似乎与NetzkeController
有关,当我点击link_to
时,它会将我发送到带有网格的页面,但NetzkeController
未使用0.10.0.rc2
执行,因此在刷新页面之前,网格没有加载,但如果我在0.8中执行相同的场景,则调用它NetzkeController
并加载网格。
以下是netzke 0.8
和0.10.0rc2
0.8
Started GET "/test/view" for 127.0.0.1 at 2014-03-19 09:07:48 -0600
Processing by TestController#view as HTML
Rendered test/view.html.erb within layouts/application (19.2ms)
Completed 200 OK in 42ms (Views: 41.6ms | ActiveRecord: 0.0ms)
[2014-03-19 09:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/netzke/ext.css" for 127.0.0.1 at 2014-03-19 09:07:48 -0600
Processing by NetzkeController#ext as CSS
Rendered text template (0.0ms)
Completed 200 OK in 2ms (Views: 0.3ms | ActiveRecord: 0.0ms)
[2014-03-19 09:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started GET "/netzke/ext.js" for 127.0.0.1 at 2014-03-19 09:07:48 -0600
Processing by NetzkeController#ext as JS
Rendered text template (0.0ms)
Completed 200 OK in 1ms (Views: 0.2ms | ActiveRecord: 0.0ms)
[2014-03-19 09:07:48] WARN Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true
Started POST "/netzke/direct/?authenticity_token=vkC6OERWwyDwHU5Hqnqpu%2BH83PNpqLnikPADBoZvrME%3D" for 127.0.0.1 at 2014-03-19 09:07:48 -0600
0.10.0rc2
Started GET "/posts" for 127.0.0.1 at 2014-03-18 13:02:58 -0600
Processing by PostsController#index as HTML
答案 0 :(得分:0)
您好我终于解决了在呈现页面的所有链接上指定方法的问题,这很奇怪因为netzke 0.8.0不需要这个可能会在官方发布时解决。
这是我的新application.html.erb,而不是语言环境中的link_to。
<!DOCTYPE html>
<html>
<head>
<title>Railroad</title>
<%= stylesheet_link_tag "application", media: "all", "data-turbolinks-track" => true %>
<%= javascript_include_tag "application", "data-turbolinks-track" => true %>
<%= load_netzke %>
<%= csrf_meta_tags %>
</head>
<body>
<div id="wrap">
<div id="header">
<div>
<h1>Demo</h1>
<hr/>
</div>
<div style="float: left;">
<% if I18n.locale == I18n.default_locale %>
<%= link_to "Español", {:locale=>'es'}, :method => :get%>
<% else %>
<%= link_to "English", {:locale=>'en'}, :method => :get%>
<%end%>
</div>
<div style="float: right;">
<% if user_signed_in? %>
<%= link_to (t :sign_out), destroy_user_session_path, :method => :delete %>
<% end %>
</div>
</div>
<div id="main-content">
<%= render 'layouts/messages' %>
<%= yield %>
</div>
<div id="footer">
<hr/>
</div>
</div>
</body>
</html>
这是我的新欢迎/ index.html.erb
<h2><%= t :post_option %></h2>
<ul>
<li><%= link_to (t :post_list), posts_path, :method => :get%></li>
<li><%= link_to (t :post_new), new_post_path%></li>
</ul>