0

I experience a weird behavior using netzke + rails 4 + extjs-4.2.1 Every time the page load at first time the div is displayed but the grid is not loaded until I refresh the page. I can't reproduce the error using rails 3 + netzke 0.8 + extjs-4.1. Could this be a netzke bug? I use the browser console and no error is displayed.

I'm currently using this version of netzke:

gem "netzke-core", "~> 0.10.0.rc2"
gem "netzke-basepack", "~> 0.10.0.rc2"

and Rails 4.0.2 with extjs-4.2.1

My 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>

My welcome/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>

My posts/index.html.erb

<h2>TEST</h2>
<%= netzke :posts, height: 400 %>

<br/>
<%=  link_to (t :back), root_path %>

My 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

My model 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

And my components/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

Thanks for your help.

Update

The problem appears to be related to NetzkeController when I click a link_to it send me to page with grid but the NetzkeController it's not executed using 0.10.0.rc2 as result the grid is not loaded until I refresh the page, but if I do the same scenario in 0.8 the NetzkeController it's called and loads the grid.

Here is the log file after the page is renderes for netzke 0.8 and 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

1 Answer 1

0

Hi i finally solve the problem specifying the method on all the links that render the page, it's weird because netzke 0.8.0 don't need this maybe this will be solved at the official release.

Here is my new application.html.erb, not the link_to on the locale.

<!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>

And here is my new welcome/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>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.