Hi, I made a simple test case using Rails 4 but I believe that netzke 0.10.0rc2 have still have a problem. The test case it's simple here is the code:views/layouts/application.html.erb<!DOCTYPE html>
<html>
<head>
<title>Railroad3</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>
<%= yield %>
</body>
</html>
views/welcome/index.html.erb<h1>Testing</h1>
<br/>
<%= link_to 'Change', test_view_path%>
views/test/view.html.erb<%= @myvar %>
<%= netzke :posts, height: 400 %>
controllers/welcome_controller.rbclass WelcomeController < ApplicationController
def index
end
def view
end
end
controllers/test_controller.rb
class TestController < ApplicationController
def view
@myvar = 'Hello World'
end
end
controllers/application_controller.rbclass ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
end
models/post.rbclass Post < ActiveRecord::Base
has_many :comments, dependent: :destroy
validates :title, presence: true, length: { minimum: 5 }
#I try to use attr_accessible and protected_attributes without success
private
def post_params
params.require(:post).permit(:title, :text)
end
end
components/post.rbclass Posts < Netzke::Basepack::Grid
def configure(c)
super
c.model = "Post"
c.columns = [
:title,
:text
]
c.prohibit_update = false
c.prohibit_delete = true
end
end
routes.rbRailroad::Application.routes.draw do
netzke
root :to => "welcome#index"
get '/test/view', to: 'test#view'
end
Gemfilesource '
https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.2'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See
https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more:
https://github.com/rails/turbolinksgem 'turbolinks'
# Build JSON APIs with ease. Read more:
https://github.com/rails/jbuildergem 'jbuilder', '~> 1.2'
#Mysql
gem 'mysql2', '~> 0.3.13'
#Netzke
gem "netzke-core", "~> 0.10.0.rc2"
gem "netzke-basepack", "~> 0.10.0.rc2"
group :doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end
# Use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.1.2'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
my migration file:class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.string :title
t.text :text
t.timestamps
end
end
end
When I click the link from the welcome page it redirects to the view page but the grid is not displayed the div is there, but it is displayed until I refresh the page, this cause the Netzke Controller to be called.
The only way I can get rid of this is modify the index.html.erb and the post method on the link<h1>Testing</h1>
<br/>
<%= link_to 'Change', test_view_path, :method => :post%>
and then change my routes.rb to use postRailroad::Application.routes.draw do
netzke
root :to => "welcome#index"
post '/test/view', to: 'test#view'
end
Using the post method could solve my problem but only if I define the routes manually, if I use resources :posts on the routes.rb it won't work.
Any help will be appreciated. Thanks, I post the same case on stackoverflow