В вашем методе создания в NotesController вы можете сделать что-то вроде
parent_chapter = Chapter.find_or_create_by(name: 'How To Program')
# parent_chapter is now either the existing chapter by that name or a new one
new_note = Note.new(params[:note])
new_note.chapter = parent_chapter # or new_note.chapter_id = parent_chapter.id
new_note.save
Метод find_or_create_by Я думаю, что вам здесь нужно. Если этот метод устарел в вашей версии rails, попробуйте first_or_create , например,
parent_chapter = Chapter.where(name: 'How To Program').first_or_create
Когда использование Нажимает Once, аргументы не передаются в на командной строке, они передаются в через Нажимать систему развертывания Once:
AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData
Например, в Вашем файле Program.cs:
foreach (string commandLineFile in AppDomain.CurrentDomain.SetupInformation.ActivationArguments.ActivationData)
{
MessageBox.Show( string.Format("Command Line File: {0}", commandLineFile) );
}
Надеюсь, это поможет.