Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/62.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在基础框架安装后重定向到模板不工作_Ruby On Rails_Zurb Foundation_Partial - Fatal编程技术网

Ruby on rails 在基础框架安装后重定向到模板不工作

Ruby on rails 在基础框架安装后重定向到模板不工作,ruby-on-rails,zurb-foundation,partial,Ruby On Rails,Zurb Foundation,Partial,在我的本地主机上,在rails(通过控制器)在数据库中创建新对象之后,我曾经让我的应用程序呈现一个模板(如果@object.save返回true)。在安装Zurb基金会后,模板没有显示,我的Flash消息也没有显示出来,新的对象投资者< /代码>也没有被创建。这些日志对我来说没什么意义。有人帮忙吗 生成的html表单 <form div class="small-6 large-centered columns"> <fieldset> <l

在我的本地主机上,在rails(通过控制器)在数据库中创建新对象之后,我曾经让我的应用程序呈现一个模板(如果@object.save返回true)。在安装Zurb基金会后,模板没有显示,我的Flash消息也没有显示出来,新的对象<代码>投资者< /代码>也没有被创建。这些日志对我来说没什么意义。有人帮忙吗

生成的html表单

<form div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<form class="new_investor" id="new_investor" action="/investors" accept-charset="UTF-8" method="post"><input name="utf8" type="hidden" value="&#x2713;" /><input type="hidden" name="authenticity_token" value="Ipbkx9oO1mWplLMXhCZA8q7nbgHr4jm9Y7BHHzLryV2va0qHzY1W04ifxu2sPHm6Iz0r7+7ZPwMsyE8sfWpiLg==" />



    <label for="investor_name">Name</label>
    <input placeholder="John Doe" type="text" name="investor[name]" id="investor_name" /> </br>

    <label for="investor_email">Email</label>
    <input placeholder="you@example.com" type="text" name="investor[email]" id="investor_email" /></br>

    <label for="investor_country">Country</label>
    <input type="text" name="investor[country]" id="investor_country" /></br>

    <label for="investor_phone">Phone</label>
    <input placeholder="+48000000" type="text" name="investor[phone]" id="investor_phone" /></br>

    <input type="submit" name="commit" value="I&#39;m interested!" class="button radius" />
</form> </fieldset>
<form>
new.html.erb

<form div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<%= form_for(@investor) do |f| %>

 <%= render 'shared/error_messages', object: f.object %>

    <%= f.label :name %>
    <%= f.text_field :name, :placeholder => "John Doe" %> </br>

    <%= f.label :email %>
    <%= f.text_field :email, :placeholder => "you@example.com" %></br>

    <%= f.label :country %>
    <%= f.text_field :country %></br>

    <%= f.label :phone %>
    <%= f.text_field :phone, :placeholder => "+48000000000" %></br>

    <%= f.submit "I'm interested!", :class => 'button radius' %>
<% end %>
    </fieldset>
<form>
反转器\u控制器.rb

class InvestorsController < ApplicationController
  def index
    @investor = Investor.first
  end

  def show
    @investor = Investor.find(params[:id])
  end

  def new
    @investor = Investor.new
  end

  def create
    @investor = Investor.new(user_params)
    if @investor.save
        flash[:success] = "Welcome, you're now on your way to success!"
        redirect_to "static_pages/welcome"
      InvestorMailer.welcome_email(@investor).deliver_now
    else
        render 'new'
    end
  end

  def update
    if @investor.update_attributes(user_params)
        flash[:success] = "Updated"
    else
        render 'edit'
    end
  end

  private

    def user_params
      params.require(:investor).permit(:name, :email, :country,
                                   :phone)
    end
end

日志文件的最后一部分:

Started GET "/investors/new?utf8=%E2%9C%93&authenticity_token=qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n%2BEhe%2Fuu7DOt29%2B50S8B11TZp1uxaxf3%2BBqgSuHp%2B3Q%3D%3D&investor%5Bname%5D=Emmanuel&investor%5Bemail%5D=lalapnt%40yahoo.com&investor%5Bcountry%5D=Poland&investor%5Bphone%5D=000000000&commit=I%27m+interested%21" for ::1 at 2015-06-12 02:18:16 +0200
Processing by InvestorsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n+Ehe/uu7DOt29+50S8B11TZp1uxaxf3+BqgSuHp+3Q==", "investor"=>{"name"=>"Emmanuel", "email"=>"lalapnt@yahoo.com", "country"=>"Poland", "phone"=>"000000000"}, "commit"=>"I'm interested!"}
  Rendered shared/_error_messages.html.erb (1.1ms)
  Rendered investors/new.html.erb within layouts/application (7.9ms)
Completed 200 OK in 163ms (Views: 162.7ms | ActiveRecord: 0.0ms)
看起来你是在向/investors/new提交表单,但这是一个GET而不是POST,因此称之为“show action of/investors/new”,而不是“create at/investors/new”

原始HTML让我看得更近-您有两个表单标记:

<form div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<%= form_for(@investor) do |f| %>

输入您的最佳详细信息
将此更改为:

<div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<%= form_for(@investor) do |f| %>

输入您的最佳详细信息
事实上,您的整个视图需要更改:

<div class="small-6 large-centered columns">
  <%= form_for(@investor) do |f| %>
    <fieldset>
      <legend> Enter your best details</legend>

      <%= render 'shared/error_messages', object: f.object %>

      <%= f.label :name %>
      <%= f.text_field :name, :placeholder => "John Doe" %> </br>

      <%= f.label :email %>
      <%= f.text_field :email, :placeholder => "you@example.com" %></br>

      <%= f.label :country %>
      <%= f.text_field :country %></br>

      <%= f.label :phone %>
      <%= f.text_field :phone, :placeholder => "+48000000000" %></br>
    </fieldset>

    <%= f.submit "I'm interested!", :class => 'button radius' %>
  <% end %>
</div>

输入您的最佳详细信息
“无名氏”%>
"you@example.com“%>

“+4800000000”%>
'按钮半径'%>
<代码>你是如何安装基金会的?通过gem、bower或手动收录?你能发布你的路线吗?我想我知道@Zoran在做什么。。。您的日志中没有任何
post
InvestorsController
,如果您使用RESTful路由,这就是所谓的
#create
方法。。。我会再次检查您的路线是否正确,以及您的表单是否正在向
InvestorsController
@Zoran post my routes.rb;)发送
post
)@siaw23绝对值得看看CDub的建议。我无法想象在基金会的安装/生成器中有任何东西会损害您的控制器或现有视图。我发布了表单代码。有什么问题吗?表面上我什么都看不见。表单生成的实际HTML是什么样子的?(仅…部分)让我们继续聊天:
Started GET "/" for ::1 at 2015-06-12 02:17:12 +0200
  ActiveRecord::SchemaMigration Load (0.3ms)  SELECT "schema_migrations".* FROM "schema_migrations"
Processing by InvestorsController#index as HTML
  Investor Load (0.5ms)  SELECT  "investors".* FROM "investors"  ORDER BY "investors"."id" ASC LIMIT 1
   (0.3ms)  SELECT COUNT(*) FROM "investors"
  CACHE (0.0ms)  SELECT COUNT(*) FROM "investors"
  Rendered investors/index.html.erb within layouts/application (2.6ms)
Completed 200 OK in 382ms (Views: 359.3ms | ActiveRecord: 2.9ms)


Started GET "/assets/foundation_and_overrides.self-464f93cbdaa7634d29f2bb979d2132db759337852a741d1de08d9aa3b85ed35e.css?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/investor.self-e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855.css?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/application.self-489c3e007974fbfaa496637ac1204061ef9d39f4dd29f1f5d1eae0ed61b80625.css?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/vendor/modernizr.self-74da3245def7569da28115667be6a85a2ad97464abe707c9829c46d8975597bc.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/jquery.self-d03a5518f45df77341bdbe6201ba3bfa547ebba8ed64f0ea56bfa5f96ea7c074.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.self-ee5396739ce46beb039f26ea629172a74143752d74f703c6c3b219fc52aecf73.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/jquery_ujs.self-8e98a7a072a6cee1372d19fff9ff3e6aa1e39a37d89d6f06861637d061113ee7.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.abide.self-f8b56c707a79139807305a5f7efc2aaa0848f0c677abcc056496f507e0192b79.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.accordion.self-d55abdcb0a7a29512be2f31f63d418cc8cc4505a0a3c71946d25484b0a0b3f4e.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.alert.self-fbde7afb61e8ffd8ab9b717f0bed1e58cb9e0144a25cc773fea634d5554f62cd.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.clearing.self-54610737b435a97590fcb176848c3c7a44c4d55d369894260fa7c28c97a70a23.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.dropdown.self-c9ee29909e266373e5e814a73fc6ea062245ddd29466d35d232448f73350d78a.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.equalizer.self-7aa743bf4660deb2fb2f601c112806a1703c430067531da3f41e4afffe19fee9.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.interchange.self-dad8415355087cb21a16fa44bac20d602344d52de5aca9e588e3588fce5dd5a7.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.joyride.self-0a5271728699423f583dd5b3b8a11bfe0dc9fb5044446bcf3218ef8ca906a82d.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.magellan.self-a50193f172f11e57b373c3001072ba2d6b34b857ab251e9ded30af5242855687.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.offcanvas.self-75bffd0c7f4f0d2992ab95f0cc6959282ebb5807da70123d40c01d76e230ec88.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.orbit.self-f8d30eb1717c874db26723f9e07901ec0a325d59263f1404ee83a616bb597ad2.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.reveal.self-95f01feb3e25e47b58b78da0021ae2fffafdee70846682067c180e0e10f7b095.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.slider.self-8911a7352cb577b6b7973b0734d57d2b624c79286558ffa36fcac0c29b2d0bee.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.tab.self-9bf6791513d1b20e213bb1aee3df0bc17128c7e18421258dc68a2a4ccabe1647.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.tooltip.self-834156796c253580629cfffc720bdc3d191b1e5a5a6ddbc1102ecd08c876516c.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation/foundation.topbar.self-105416f061562f07c6a0a8057d68282fdc1eeb5dc306713fcae6c9a53001fc55.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/foundation.self-abe4ee7a105042f73b12b1f1a28788522d2f253445a475a94ab4d6e1f7b0ec52.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/turbolinks.self-c37727e9bd6b2735da5c311aa83fead54ed0be6cc8bd9a65309e9c5abe2cbfff.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/investor.self-877aef30ae1b040ab8a3aba4e3e309a11d7f2612f44dde450b5c157aa5f95c05.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/assets/application.self-79a300d240bbf145c9af961805bc87f18e9f73bd1cda275895295c80d8552d3f.js?body=1" for ::1 at 2015-06-12 02:17:13 +0200


Started GET "/investors/new" for ::1 at 2015-06-12 02:17:16 +0200
Processing by InvestorsController#new as HTML
  Rendered shared/_error_messages.html.erb (4.2ms)
  Rendered investors/new.html.erb within layouts/application (20.6ms)
Completed 200 OK in 113ms (Views: 111.7ms | ActiveRecord: 0.0ms)


Started GET "/investors/new" for ::1 at 2015-06-12 02:18:04 +0200
Processing by InvestorsController#new as HTML
  Rendered shared/_error_messages.html.erb (0.0ms)
  Rendered investors/new.html.erb within layouts/application (2.7ms)
Completed 200 OK in 89ms (Views: 88.6ms | ActiveRecord: 0.0ms)


Started GET "/investors/new?utf8=%E2%9C%93&authenticity_token=qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n%2BEhe%2Fuu7DOt29%2B50S8B11TZp1uxaxf3%2BBqgSuHp%2B3Q%3D%3D&investor%5Bname%5D=Emmanuel&investor%5Bemail%5D=lalapnt%40yahoo.com&investor%5Bcountry%5D=Poland&investor%5Bphone%5D=000000000&commit=I%27m+interested%21" for ::1 at 2015-06-12 02:18:16 +0200
Processing by InvestorsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n+Ehe/uu7DOt29+50S8B11TZp1uxaxf3+BqgSuHp+3Q==", "investor"=>{"name"=>"Emmanuel", "email"=>"lalapnt@yahoo.com", "country"=>"Poland", "phone"=>"000000000"}, "commit"=>"I'm interested!"}
  Rendered shared/_error_messages.html.erb (1.1ms)
  Rendered investors/new.html.erb within layouts/application (7.9ms)
Completed 200 OK in 163ms (Views: 162.7ms | ActiveRecord: 0.0ms)
Started GET "/investors/new?utf8=%E2%9C%93&authenticity_token=qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n%2BEhe%2Fuu7DOt29%2B50S8B11TZp1uxaxf3%2BBqgSuHp%2B3Q%3D%3D&investor%5Bname%5D=Emmanuel&investor%5Bemail%5D=lalapnt%40yahoo.com&investor%5Bcountry%5D=Poland&investor%5Bphone%5D=000000000&commit=I%27m+interested%21" for ::1 at 2015-06-12 02:18:16 +0200
Processing by InvestorsController#new as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"qgXmHuloO7rKfYIUXFH5PVjsLDjpYcNDsX6gIff71a4n+Ehe/uu7DOt29+50S8B11TZp1uxaxf3+BqgSuHp+3Q==", "investor"=>{"name"=>"Emmanuel", "email"=>"lalapnt@yahoo.com", "country"=>"Poland", "phone"=>"000000000"}, "commit"=>"I'm interested!"}
  Rendered shared/_error_messages.html.erb (1.1ms)
  Rendered investors/new.html.erb within layouts/application (7.9ms)
Completed 200 OK in 163ms (Views: 162.7ms | ActiveRecord: 0.0ms)
<form div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<%= form_for(@investor) do |f| %>
<div class="small-6 large-centered columns">
    <fieldset>
        <legend> Enter your best details</legend>
<%= form_for(@investor) do |f| %>
<div class="small-6 large-centered columns">
  <%= form_for(@investor) do |f| %>
    <fieldset>
      <legend> Enter your best details</legend>

      <%= render 'shared/error_messages', object: f.object %>

      <%= f.label :name %>
      <%= f.text_field :name, :placeholder => "John Doe" %> </br>

      <%= f.label :email %>
      <%= f.text_field :email, :placeholder => "you@example.com" %></br>

      <%= f.label :country %>
      <%= f.text_field :country %></br>

      <%= f.label :phone %>
      <%= f.text_field :phone, :placeholder => "+48000000000" %></br>
    </fieldset>

    <%= f.submit "I'm interested!", :class => 'button radius' %>
  <% end %>
</div>