Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Nested Resource
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  12 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Lucas Lima de Souza  
View profile   Translate to Translated (View Original)
 More options Jul 13 2012, 2:51 pm
From: Lucas Lima de Souza <lucaslim...@gmail.com>
Date: Fri, 13 Jul 2012 11:51:36 -0700 (PDT)
Local: Fri, Jul 13 2012 2:51 pm
Subject: Nested Resource

Como faço para o simple_form acessar o post de uma action gerada de um:

resources :users do
  resources :lists
end

Desejo criar uma nova lista e essa lista depende do id do usuário.

simple_form tenta acessar por lists_path mais gera:

 undefined method `lists_path' for #<#<Class:0xa68f4c0>:0xa68d364>

valeu =D


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile   Translate to Translated (View Original)
 More options Jul 13 2012, 3:11 pm
From: Rafael Mendonça França <rafaelmfra...@gmail.com>
Date: Fri, 13 Jul 2012 16:11:10 -0300
Local: Fri, Jul 13 2012 3:11 pm
Subject: Re: Nested Resource

Você poderia mandar a código do formulário?

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca

2012/7/13 Lucas Lima de Souza <lucaslim...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
thiagocifani  
View profile   Translate to Translated (View Original)
 More options Jul 13 2012, 3:29 pm
From: thiagocifani <cifani.thi...@gmail.com>
Date: Fri, 13 Jul 2012 16:29:55 -0300
Local: Fri, Jul 13 2012 3:29 pm
Subject: Re: Nested Resource

tenta adicionar users_lists_path ao inves de apenas lists_path
 já que é um resource aninhado.

Em 13 de julho de 2012 16:11, Rafael Mendonça França <
rafaelmfra...@gmail.com> escreveu:

--
thiagocifani
http://thiagocifani.wordpress.com/
twitter.com/thiagocifani
del.icio.us/thiagocifani
<http://del.icio.us/thiagocifani>

 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile   Translate to Translated (View Original)
 More options Jul 13 2012, 3:32 pm
From: Rafael Mendonça França <rafaelmfra...@gmail.com>
Date: Fri, 13 Jul 2012 16:32:53 -0300
Local: Fri, Jul 13 2012 3:32 pm
Subject: Re: Nested Resource

Outro jeito é aninhar os dois models

simple_form_for [@user, @list]

foi exatamente por isso que eu pedi o código do formulário.

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca

2012/7/13 thiagocifani <cifani.thi...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
thiagocifani  
View profile   Translate to Translated (View Original)
 More options Jul 13 2012, 3:54 pm
From: thiagocifani <cifani.thi...@gmail.com>
Date: Fri, 13 Jul 2012 16:54:05 -0300
Local: Fri, Jul 13 2012 3:54 pm
Subject: Re: Nested Resource

Sim Rafael, eu uso mais do jeito que vc falou mesmo ;)

Vamos ver se ele manda o código .

Enviado via iPad

Em Jul 13, 2012, às 4:32 PM, Rafael Mendonça França <rafaelmfra...@gmail.com> escreveu:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas Lima de Souza  
View profile   Translate to Translated (View Original)
 More options Jul 16 2012, 10:41 am
From: Lucas Lima de Souza <lucaslim...@gmail.com>
Date: Mon, 16 Jul 2012 07:41:49 -0700 (PDT)
Local: Mon, Jul 16 2012 10:41 am
Subject: Re: Nested Resource

Alinhando os modelos no form:

<%=simple_form_for [@user,@list] do |f| %>

<p>
<%=f.label :name, "Name List" %><br />
<%=f.text_field :name, :size => 50 %>
<%=f.collection_radio_buttons :status,
[['public','Public'],['private','Private']], :first, :last  %>
</p>

<div id="tasks">
<h3> Taks</h3>

<%=f.simple_fields_for :tasks do |task_form| %>
<%= render 'task_form', :f => task_form %>
<% end %>

</div>

<%= f.submit "Submit"%>
<%=image_tag '/icons/icon-add.png'%><%= link_to_add_fields("Add
task",f,:tasks)%>

<% end %>

com os resources:
 resources :users, :only => :show do
    resources :lists, :controller => "users/lists"
  end

o erro continua:

undefined method `lists_path'


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile   Translate to Translated (View Original)
 More options Jul 16 2012, 10:50 am
From: Rafael Mendonça França <rafaelmfra...@gmail.com>
Date: Mon, 16 Jul 2012 11:50:56 -0300
Local: Mon, Jul 16 2012 10:50 am
Subject: Re: Nested Resource

Mande o stack trace completo por favor.

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca

2012/7/16 Lucas Lima de Souza <lucaslim...@gmail.com>


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas Lima de Souza  
View profile  
 More options Jul 16 2012, 10:53 am
From: Lucas Lima de Souza <lucaslim...@gmail.com>
Date: Mon, 16 Jul 2012 07:53:07 -0700 (PDT)
Local: Mon, Jul 16 2012 10:53 am
Subject: Re: Nested Resource

executando rake routes, percebi que o POST não tem path. =|

user_lists GET    /users/:user_id/lists(.:format)          users/lists#index
                         POST   /users/:user_id/lists(.:format)        
 users/lists#create
new_user_list GET    /users/:user_id/lists/new(.:format)    
 users/lists#new
edit_user_list GET    /users/:user_id/lists/:id/edit(.:format)
users/lists#edit
user_list GET    /users/:user_id/lists/:id(.:format)      users/lists#show
           PUT    /users/:user_id/lists/:id(.:format)    
 users/lists#update
                         DELETE /users/:user_id/lists/:id(.:format)    
 users/lists#destroy
                    user GET    /users/:id(.:format)                    
users#show

On Friday, July 13, 2012 3:51:36 PM UTC-3, Lucas Lima de Souza wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas Lima de Souza  
View profile  
 More options Jul 16 2012, 10:55 am
From: Lucas Lima de Souza <lucaslim...@gmail.com>
Date: Mon, 16 Jul 2012 07:55:02 -0700 (PDT)
Local: Mon, Jul 16 2012 10:55 am
Subject: Re: Nested Resource

Showing *
/home/lucas/workspaceRuby/TaskCommunity/app/views/users/lists/_form.html.er b
* where line *#4* raised:

undefined method `lists_path' for #<#<Class:0xabb77cc>:0xac33020>

Extracted source (around line *#4*):

1: <%= render 'validate' %>
2:
3: <div class="new_list">
4:      <%=simple_form_for [@user,@list] do |f| %>
5:
6:              <p>
7:                      <%=f.label :name, "Name List" %><br />

Trace of template inclusion: app/views/users/lists/new.html.erb

Rails.root: /home/lucas/workspaceRuby/TaskCommunity
Application Trace <http://localhost:3000/users/3/lists/new#> | Framework
Trace <http://localhost:3000/users/3/lists/new#> | Full Trace<http://localhost:3000/users/3/lists/new#>

app/views/users/lists/_form.html.erb:4:in `_app_views_users_lists__form_html_erb__899148841_90293870'
app/views/users/lists/new.html.erb:4:in `_app_views_users_lists_new_html_erb___40585645_89532210'

On Friday, July 13, 2012 3:51:36 PM UTC-3, Lucas Lima de Souza wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Carlos Antonio da Silva  
View profile  
 More options Jul 16 2012, 11:04 am
From: Carlos Antonio da Silva <carlosantoniodasi...@gmail.com>
Date: Mon, 16 Jul 2012 12:04:47 -0300
Local: Mon, Jul 16 2012 11:04 am
Subject: Re: Nested Resource

A variável @user existe? Ou seria current_user, @current_user, ou ainda algo diferente?  

--  
At.
Carlos Antonio

On Monday, July 16, 2012 at 11:55 AM, Lucas Lima de Souza wrote:


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Rafael Mendonça França  
View profile  
 More options Jul 16 2012, 11:04 am
From: Rafael Mendonça França <rafaelmfra...@gmail.com>
Date: Mon, 16 Jul 2012 12:04:39 -0300
Local: Mon, Jul 16 2012 11:04 am
Subject: Re: Nested Resource

Isso deveria funcionar como você pode ver aqui:
https://github.com/rails/rails/blob/beba8267c96a3dbc1f505ecc099dbf14d...

E POST tem path sim. É user_lists o mesmo que o GET na coleção.

Eu não acho que tenha um bug no SimpleForm mas você poderia trocar o
`simple_form_for` por `form_for`?

Rafael Mendonça França
http://twitter.com/rafaelfranca
https://github.com/rafaelfranca

On Mon, Jul 16, 2012 at 11:55 AM, Lucas Lima de Souza <lucaslim...@gmail.com


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Lucas Lima de Souza  
View profile  
 More options Jul 16 2012, 11:32 am
From: Lucas Lima de Souza <lucaslim...@gmail.com>
Date: Mon, 16 Jul 2012 08:32:14 -0700 (PDT)
Local: Mon, Jul 16 2012 11:32 am
Subject: Re: Nested Resource

Valeu galera!!!

Colocando simple_form_for [current_user, @list] deu certo. =D

o Form final ficou assim:

<%=simple_form_for [current_user,@list] do |f| %>

<p>
<%=f.label :name, "Name List" %><br />
<%=f.text_field :name, :size => 50 %>
<%=f.collection_radio_buttons :status,
[['public','Public'],['private','Private']], :first, :last  %>
</p>

<div id="tasks">
<h3> Taks</h3>

<%=f.simple_fields_for :tasks do |task_form| %>
<%= render 'task_form', :f => task_form %>
<% end %>

</div>

<%= f.submit "Submit"%>
<%=image_tag '/icons/icon-add.png'%><%= link_to_add_fields("Add
task",f,:tasks)%>

<% end %>

\o/  :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »