我想定制以下内容
我想创建一个partials来为DRY的不同命名空间在索引面板中呈现一些数据
我现在正在写作
index do
render 'index', user: :user
end
//_index.html.arb
column :id
column 'Customer Name', :name
column :mobile
column :recipient_number
column :cash_in_hand do |customer|
number_to_currency(customer.cash_in_hand, unit: "\u20B9", precision: 2)
end
column "Due Balance" do |customer|
number_to_currency(customer.due_balance, unit: "\u20B9", precision: 2)
end
actions
Run Code Online (Sandbox Code Playgroud) 这不起作用(抛出Nullpointer异常)
String s = null;
System.out.println(s);
System.out.println(String.valueOf(null));
Run Code Online (Sandbox Code Playgroud)
但这是
String s = null;
System.out.println(s);
System.out.println(String.valueOf(s));
Run Code Online (Sandbox Code Playgroud)
为什么?无法得到.我想了解背后的逻辑.
我的标准代码
class Bank < ApplicationRecord
has_one :address
accepts_nested_attributes_for :address
end
class Address < ApplicationRecord
belongs_to :bank
end
Run Code Online (Sandbox Code Playgroud)
我的控制器
def create
@bank = Bank.new(bank_params)
respond_to do |format|
if @bank.save
format.html { redirect_to @bank, notice: 'Bank was successfully created.' }
format.json { render :show, status: :created, location: @bank }
else
format.html { render :new }
format.json { render json: @bank.errors, status: :unprocessable_entity }
end
end
end
def bank_params
params.require(:bank).permit(:code, :currency, :name, :mobile_1, :mobile_2, :email, address_attributes: [:id, :name, :area, :pin_code, :city_id] )
end …Run Code Online (Sandbox Code Playgroud)