Strange error at render partial

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”) %>
<%= text_field_tag :lesson_name, nil, class: “form-control” %>
<%= label_tag(:lesson_icon, “Choise icon”) %>
<%= select_tag “lesson_icon”, options_for_select([ “ico03”,
“ico04”,“ico05”,“ico06” ])%>

<%= label_tag(:Title, “Subtitle 1”) %>
<%= text_field_tag :sublesson_title, nil, class: “form-control” %>
<%= label_tag(:title, “Content”) %>
<%=text_area_tag ‘content’, nil, rows: 3, class: ‘form-control’%>

<%= label_tag(:video, “Video link”) %>

<%= text_field_tag :video_link, nil, class: “form-control” %>
<%= 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

change ur form like this

<%= form_for @lesson do |f| %>
<%=f.label :lesson_name, “Lesson title” %>
<%= f.text_field :lesson_name, class: “form-control” %>
<%= f.submit %>

Thanks vishal! yes and what you sad was a problem but it crash before
do.
It’s keep telling me First argument in form cannot contain nil or be
empty

On Thursday, August 7, 2014 8:24:12 AM UTC+2, Ruby-Forum.com User wrote:

<%= label_tag(:lesson_icon, “Choise icon”) %>
<%= label_tag(:video, “Video link”) %>

def create
@lesson=Lesson.new
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

As @vishal told it, your form should be coded as follows:

<%= form_for(@lesson) do |f| %>
<%= f.label :lesson_name %>

<%= f.text_field :lesson_name %>
<% end %>

Try it as it is and post the errors full stack trace to have more idea
on
what is going on there. It is really difficult to figure out without
that.
Your model should be named as Lesson.
You should have routes defined for Lesson resource as well.