我正在尝试使用simple_form单选按钮集合来对我的帖子进行分类,但是,似乎模型无法读取该值。
以下是代码
class CreatePosts < ActiveRecord::Migration
def change
create_table :posts do |t|
t.text :content
t.integer :category
t.references :user, index: true, foreign_key: true
t.references :comment
t.timestamps null: false
end
end
end
虽然我发布了以下内容
<%= simple_form_for:post do |f| %>
<%= f.collection_radio_buttons :category, [[1,"Joke "],[2,"Gossip "],[3,"option3 "],[4,"option4 "]], :first, :last %>
<%= f.text_area :content %>
<%= f.button :submit, "Post" %>
<% end %>
无论我点击单选按钮。结果是一样的
Post Load (12.7ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" DESC LIMIT $1 [["LIMIT", 1]]
=> #<Post id: 17, content: "test again", category: nil, user_id: 1, created_at: "2017-12-13 05:47:09", updated_at: "2017-12-13 05:47:09">
类别:无
如何通过单击单选按钮输入值?
答案 0 :(得分:1)
您错过了<Connector port="8086" ...>
<Server port="8007" shutdown="SHUTDOWN">
<Connector port="8010" protocol="AJP/1.3" redirectPort="8443" />
,更改了行
]
带
<%= f.collection_radio_buttons :category, [[1,"Joke "],[2,"Gossip "],[3,"option3 "],[4,"option4 "], :first, :last %>
答案 1 :(得分:0)
你的SELECT
A.LASTNAME, A.FIRSTNAME, A.DATEFROM, A.DATETO, A.ROOMNUMBER, A.CITY, A.COUNTRY, A.STATUS, A.DAYS
FROM
(SELECT LASTNAME, FIRSTNAME, MAX(DATETO) AS MOST_RECENT_STAY
FROM YOUR_TABLE
GROUP BY LASTNAME, FIRSTNAME) Z
INNER JOIN
YOUR_TABLE A
ON Z.LASTNAME = A.LASTNAME AND Z.FIRSTNAME = A.FIRSTNAME AND Z.MOST_RECENT_STAY = A.DATETO;
列是整数类型所以我认为数组的secound参数应该是整数而不是字符串,让我们尝试一下。
compile 'com.google.firebase:firebase-messaging:11.6.2'