博客:有很多帖子和帖子:属于博客。但博客也以同样的方式与用户相关联。 (博客嵌套用户)。 帖子的节目页面有一个链接:
BoxLayout
我发送blog_id从帖子中的隐藏表单中获取。它工作正常(http地址:)
import java.awt.*;
import java.text.*;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
public class BoxLayoutQuandary {
private JComponent ui = null;
BoxLayoutQuandary() {
initUI();
}
public void initUI() {
if (ui != null) {
return;
}
ui = new JPanel(new BorderLayout(4, 4));
ui.setBorder(new EmptyBorder(4, 4, 4, 4));
NumberFormat numberFormat = new DecimalFormat("##.#");
// Create the text fields and set them up.
JFormattedTextField priemerKolesa = new JFormattedTextField(numberFormat);
priemerKolesa.setColumns(8);
JFormattedTextField hrubkaNavinu = new JFormattedTextField(numberFormat);
hrubkaNavinu.setColumns(6);
// Layout the text fields in a panel.
JPanel fieldPane = new JPanel();
fieldPane.setLayout(new BoxLayout(fieldPane, BoxLayout.Y_AXIS));
ui.add(fieldPane);
JPanel priemerKolesaPanel = new JPanel();
priemerKolesaPanel.add(priemerKolesa);
fieldPane.add(priemerKolesaPanel);
JPanel hrubkaNavinuPanel = new JPanel();
hrubkaNavinuPanel.add(hrubkaNavinu);
fieldPane.add(hrubkaNavinuPanel);
}
public JComponent getUI() {
return ui;
}
public static void main(String[] args) {
Runnable r = new Runnable() {
@Override
public void run() {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (Exception useDefault) {
}
BoxLayoutQuandary o = new BoxLayoutQuandary();
JFrame f = new JFrame(o.getClass().getSimpleName());
f.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
f.setLocationByPlatform(true);
f.setContentPane(o.getUI());
f.pack();
f.setMinimumSize(f.getSize());
f.setVisible(true);
}
};
SwingUtilities.invokeLater(r);
}
}
但是当我按下帖子的创建按钮(创建后)后试图找到带有帖子ID的博客。 地址:
错误: 找不到带有' id' = 2 的博客 在线:
= link_to 'Edit', edit_post_path(blog_id: blog.id)
问题是如果我删除路径的参数我无法在编辑中以隐藏形式(blog_id)设置它。我该如何解决?
UPD: 路线:
http://localhost:3000/posts/1/edit?blog_id=1
邮政控制人:
= link_to 'Edit', edit_post_path(blog_id: blog.id)