如何在产品展示页面中呈现Enquery表单

时间:2017-01-07 07:21:32

标签: ruby-on-rails ruby

我有一个产品的显示页面,显示有关产品的信息。我在同一个展示页面上也有一个enquery表单,因此用户可以发送有关该产品的enquery。必须将enquery数据保存到// One minute to midnight in Tehran, daylight saving not applied new Date(Date.UTC(2017,2,21,20,29)); // Tue Mar 21 2017 23:59:00 GMT+0330 (IRST) // At midnight in Tehran, daylight saving applied new Date(Date.UTC(2017,2,21,20,30)); // Wed Mar 22 2017 01:00:00 GMT+0430 (IRST) 模型中,并且相应的Enquery应该{ {1}}和EnqueresController次操作。

如何在Rails中完成?
任何帮助都非常感谢。在此先感谢!

index

1 个答案:

答案 0 :(得分:1)

renderToString

const store = createStore(
  reducers,

  // an object that provides the initial generic state
  res.viewModel.__INITIAL_STATE__ || Object.create(null),

  middlewares
);

// now the store is pristine and calling store.getState()
// I will retrieve an invalid version of the state

const markup = renderToString(
  <Provider store={store}>
    {<RouterContext {...renderProps} />}
  </Provider>
);

// now the store is correctly computed and calling
// store.getState() gets the right version but the markup
// generated is still old. Only recalling `renderToString` will get 
// the right markup

const markup2 = renderToString(
  <Provider store={store}>
    {<RouterContext {...renderProps} />}
  </Provider>
);
之后在app/controllers/products_controller.rb

的节目视图中

class ProductsController < ApplicationController

  // initialize your enquiry model object here
  // since you are showing the form on show page

  def show
    @products = Products.all
    @enquiry  = Enquiry.new 
  end

end