我明白了!
= link_to 'Zurück', page_path
这在新页面中不起作用。页面尚未创建,所以我不能再回到它... 这确实适用于“编辑”,页面存在
努力让rspec运行的一个很好的理由: - )
无论如何,感谢您的评论!
我还有一点......
路由似乎有效。但我的形式似乎是问题?!
这是我的观点/ pages / new.html.haml
= render 'form'
如果我这样做,它会被呈现: %p我应该是新页面的表格... =#render'form'
所以我的_form.html.haml似乎有问题 - 适用于“编辑”
= javascript_include_tag "#{root_url}javascripts/tiny_mce_head.js"
= form_for @page do |f|
-if @page.errors.any?
#error_explanation
%h2= "#{pluralize(@page.errors.count, "error")} prohibited this page from being saved:"
%ul
- @page.errors.full_messages.each do |msg|
%li= msg
.field
= f.text_area( :content, :class => 'mce_editor')
.field
= f.label :fan_only
= f.check_box :fan_only
.field
= f.label :short_name
%br
= f.text_field :short_name
.field
= f.label :title
%br
= f.text_field :title
.actions
= f.submit 'Save'
= link_to 'Zurück', page_path
任何想法???
我已经尝试过没有javascript_include_tag
原帖
我无法再创建新页面了。它正在工作,我不知道为什么它不再存在!
如果我浏览http://localhost:3000/pages/new
我收到以下消息:
No route matches {:action=>"show", :controller=>"pages"}
这些是我的路线
scope '/my-scope' do
resources :pages do
resources :articles
end
end
root :to => 'pages#index'
rake routes
page_articles GET /my-scope/pages/:page_id/articles(.:format) {:action=>"index", :controller=>"articles"}
POST /my-scope/pages/:page_id/articles(.:format) {:action=>"create", :controller=>"articles"}
new_page_article GET /my-scope/pages/:page_id/articles/new(.:format) {:action=>"new", :controller=>"articles"}
edit_page_article GET /my-scope/pages/:page_id/articles/:id/edit(.:format) {:action=>"edit", :controller=>"articles"}
page_article GET /my-scope/pages/:page_id/articles/:id(.:format) {:action=>"show", :controller=>"articles"}
PUT /my-scope/pages/:page_id/articles/:id(.:format) {:action=>"update", :controller=>"articles"}
DELETE /my-scope/pages/:page_id/articles/:id(.:format) {:action=>"destroy", :controller=>"articles"}
pages GET /my-scope/pages(.:format) {:action=>"index", :controller=>"pages"}
POST /my-scope/pages(.:format) {:action=>"create", :controller=>"pages"}
new_page GET /my-scope/pages/new(.:format) {:action=>"new", :controller=>"pages"}
edit_page GET /my-scope/pages/:id/edit(.:format) {:action=>"edit", :controller=>"pages"}
page GET /my-scope/pages/:id(.:format) {:action=>"show", :controller=>"pages"}
PUT /my-scope/pages/:id(.:format) {:action=>"update", :controller=>"pages"}
DELETE /my-scope/pages/:id(.:format) {:action=>"destroy", :controller=>"pages"}
root / {:controller=>"pages", :action=>"index"}
controllers / pages_controller.rb methodes show 和 new
# GET /pages/1
# GET /pages/1.json
def show
@page = Page.find(params[:id])
respond_to do |format|
format.html # show.html.erb
format.json { render json: @page }
end
end
# GET /pages/new
# GET /pages/new.json
def new
@page = Page.new
respond_to do |format|
format.html # new.html.erb
format.json { render json: @page }
end
end
这是我的观点/ pages.html.haml
%p#notice= notice
%content.viewmode
= raw parse_content @page.content
-#if admin?
= link_to 'Edit page', edit_page_path(@page)
= link_to 'New page', new_page_path
= link_to 'Destroy page', @page, :confirm => 'Are you sure to delete page #{@page.title}?', :method => :delete
= link_to 'New article', new_page_article_path(@page)
-if @page.articles.empty?
/
= "No articles for page #{@page.short_name}"
- else
%ul.article_list
= show_articles
如果有人能给我一些想法从哪里开始搜索,我会很高兴的。 我尝试了但是我没有进一步。
答案 0 :(得分:2)
您正在使用范围,因此您的网址应为http://localhost:3000/my-scope/pages/new