Im getting the following error message:
undefined method `user_registration_path' for #<#<Class:0x10f227cd8>:0x10f5f6d50>
Extracted source (around line #3):
1: <h2>Sign up</h2>
2:
3: <%= form_for(resource_name, resource, :url => registration_path(resource_name)) do |f| %>
4: <%= f.error_messages %>
5: <p><%= f.label :email %></p>
6: <p><%= f.text_field :email %></p>
I checked everything and i didnt found an error, i had just created the project and installed the plugin.
I was using a old version of the devise plugin in the new version of the ror. =x
Related
I have a rails app where I can create and edit records. I've created a form to enter data which works fine when I use the new/create actions. It will create a record no problem. But when I hit the edit action it gives me an undefined method 'model_name' for NilClass:Class.
I'm not sure what this means. Can someone give me a hand?
Form:
<%= form_for(#patient) do |f| %>
<%= f.label :Patient_Last_Name %>
<%= f.text_field :patient_last %>
<%= f.label :Patient_First_Name %>
<%= f.text_field :patient_first %>
<%= f.label :Patient_DOB %>
<%= f.date_select :patient_dob %>
<%= f.label :Primary_Diagnosis %>
<%= f.collection_select(:diagnosis_id, Diagnosis.all, :id, :diagnosis_name)%></br>
<%= f.label :Primary_Physician %>
<%= f.collection_select(:physician_id, Physician.all, :id, :physician_name)%></br>
<%= f.button :submit %>
<% end %>
View Code:
<td><%= link_to 'Edit', edit_patient_path(patient), :class => 'btn btn-close btn-mini'%></td>
Controller Code:
def edit
#patient = Patient.find(params[:id])
end
Edit view:
<%= render 'form' %>
When I remove the partial render from the form, the URL will go to the correct route/url. But I keep getting that error when the form partial is rendered.
There was an extra end statement in my controller which was cutting off half of the class which included the edit action. This was not allowing me to use the edit action. Once this typo was fixed things started working normally.
Sorry for the confusion.
I'm trying to achieve the following, by pushing a button on a page the user to get a random item from the database which will be showed, but will have an attribute editable. The problem I hit into, is the following I don't know how to pass an random id(valid in the database), to be rendered in my partial, but still to be able to update the specific attribute.
Problem from the title:
SyntaxError in Tasks#main
Showing /home/bogdan/ex/bored/app/views/tasks/main.html.erb where line #1 raised:
/home/bogdan/ex/bored/app/views/tasks/main.html.erb:1: syntax error, unexpected ',', expecting ')'
...uffer.append= form_for (:task, :url => {:action =>'rand_tas...
... ^
/home/bogdan/ex/bored/app/views/tasks/main.html.erb:1: syntax error, unexpected ')', expecting keyword_end
...url => {:action =>'rand_task'}) do |f|#output_buffer.safe_co...
... ^
../app/views/tasks/main.html.erb:8: syntax error, unexpected keyword_ensure, expecting $end
Extracted source (around line #1):
1: <%= form_for (:task, :url => {:action =>'rand_task'}) do |f|%>
2: <%= render(:partial => "rand_show", :locals => {:f => f}) %></p>
3: <%end%>
4:
Trace of template inclusion: app/views/tasks/main.html.erb
I was trying to pass the rand_task output object to the _rand_show.html.erb and afterwartds call a new editable form only for the attr i'm intressted in by the id
form:
<%= form_for(#task = Task.new) do |f| %>
<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name, :disabled=>true %>
</div>
<div class="field">
<%= f.label :category %><br />
<%= f.text_field :category, :disabled=>true %>
</div>
<div class="actions">
<%= f.submit %>
</div>
<% end %>
random method:
def rand_task
if params[:id] == 'random'
#task = Task.order('RANDOM()').first
else
#task = Task.order('RANDOM()').first // if not i get a nill related error.
end
end
Please help why do i get the above mentioned error? IS the concept i'm thinking about wrong?
<%= form_for (:task, :url => {:action =>'rand_task'}) do |f| %>
^
The problem is the space between form_for and (. If you remove the space it should work.
I am having a weird issue with Devise. I have lists with tasks on them. When you delete a task all of the sudden I get a template error having to do with the User.
It seems like the delete method causes the session to logout and therefore can't find the User when trying to load the template.
I have no idea why this is happening:
_task.html
<div class="tasks">
<%= div_for task do %>
<%= link_to 'Delete', task_path(task), :method => :delete, :class => "delete", :remote => true %> | <%= content_tag(:div, task.task, :class => "task-body") %>
<% end %>
</div>
destroy.js.erb
$("#task_<%= #task.id %>").fadeOut();
ERROR AFTER RELOADING PAGE, THIS IS FOR THE ACCOUNT, LOGOUT ETC in HEADER
No route matches {:action=>"show", :controller=>"users"}
Extracted source (around line #5):
2: <div id ="login">
3: <ul>
4: <li><%= link_to "Sign out", destroy_user_session_path %></li>
5: <li><%= link_to "Account", user_path(current_user) %></li>
6: <li><%= link_to "Things", user_things_path(current_user) %></li>
7:
8: </ul>
Thanks in advance!
After a little more searching I found the answer here on stackoverflow, so credit should go to justsee from this previous question
The request will not include the required CSRF data, and as of
Rails 3.0.4 the session is silently reset instead of throwing an
ActionController::InvalidAuthenticityToken error.
To fix this include the following in your layout:
<%= javascript_include_tag :defaults %>
<%= csrf_meta_tag %>
hi i am using show_for gem and it gives me error like: undefined method `to_key' for # in app/views/messages/index.html.erb where line #46 raised:
my view look like these:
46: <%= show_for #messages do |s| %>
47: <%= s.attribute :subject %>
48: <%= s.attribute :message %>
49: <% end %>
my controller code look like:
#messages= Message.all
please help me what i am doing wrong. thanks in advance
I do not know this gem but according to its documentation, show_for is not supposed to receive a collection as argument (#messages) but a single object. I might be wrong.
With this supposition, I would to :
<% #messages.each do |message| %>
<%= show_for message do |s| %>
<%= s.attribute :subject %>
<%= s.attribute :message %>
<% end %>
<% end %>
I am using the nested_form_for gem for the first time. I don't know if this is an issue or if I am using it wrong, but I am getting an "undefined method nested_form_for" error.
I have a pretty regular form as you can see:
<%= nested_form_for #user do |f| %>
<%= f.fields_for :godfathers do |godfather_form| %>
<%= godfather_form.label :name %> <br/>
<%= godfather_form.text_field :name %> <br/>
<%= godfather_form.label :description %> <br/>
<%= godfather_form.text_field :description %> <br/>
<%= godfather_form.link_to_remove "Remove this godfather" %>
<% end %>
<%= f.link_to_add "Add a godfather", :godfathers %>
<% end %>
By the way, I installed the gem and ran the: rails generate nested_form:install command to generate the nested_form.js file that I included in my layout after the jquery inclusion(<%= javascript_include_tag :default, 'nested_form' %>).
Anyone using this gem as well?
Thanks!
Everything looks right and if the generator ran the gem should be in place. Have you restarted your server since adding the plugin to your Gemfile?