change ur form like this <%= form_for @lesson do |f| %> <%=f.label :lesson_name, "Lesson title" %></br> <%= f.text_field :lesson_name, class: "form-control" %></br> <%= f.submit %>
On Thu, Aug 7, 2014 at 11:53 AM, Turcu Marius <li...@ruby-forum.com> wrote: > Hello! I have some problems > > I have a pages controler and a view called add_lesson.In this view i use > a partial to another view of lesson controller.This is the partial > _show.html.erb > > <%= form_for @lesson do %> > <%= label_tag(:lesson_name, "Lesson title") %></br> > <%= text_field_tag :lesson_name, nil, class: "form-control" %></br> > <%= label_tag(:lesson_icon, "Choise icon") %> > <%= select_tag "lesson_icon", options_for_select([ "ico03", > "ico04","ico05","ico06" ])%></br></br> > > <%= label_tag(:Title, "Subtitle 1") %></br> > <%= text_field_tag :sublesson_title, nil, class: "form-control" %></br> > <%= label_tag(:title, "Content") %></br> > <%=text_area_tag 'content', nil, rows: 3, class: 'form-control'%></br> > > > > <%= label_tag(:video, "Video link") %><br> > <%= text_field_tag :video_link, nil, class: "form-control" %></br> > <%= submit_tag("Submit", class: "btn btn-primary") %> > > > <% end %> > > IN lesson controler i have > def index > end > > def create > #render text: params.inspect > @lesson = Lesson.new(lesson_params) > > if @lesson.save > redirect_to lessons_url > else > render 'new' > end > end > def new > @lesson=Lesson.new > @lesson.build_sublesson > end > def show > @lesson=Lesson.all > end > > private > > def lesson_params > params.require(:lesson).permit(:lesson_name, :lesson_icon) > end > > > When i submit the form i receive an error like this First argument in > form cannot contain nil or be empty. It is from @lesson in the form but > i don't know how to fix it. Please help > > -- > Posted via http://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to rubyonrails-talk+unsubscr...@googlegroups.com. > To post to this group, send email to rubyonrails-talk@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/rubyonrails-talk/e4be687c09bf52509f00b9dd4bce5443%40ruby-forum.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-talk@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAFpxYFLhv7F0e8UXMFP2CzevLu1Z_7FEYFof8QENLufj0wpQcg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.