def create
@cart_items = params[:cart_items]
@cart_items.each do |c|
@cart_item = CartItem.new(c)
if @cart_item.qty.present?
@cart_item.cart_id = @cart.id
@cart_item.save
end
end
redirect_to :back
end
<%= form_tag cart_items_path do %>
<% @cart_items.each do |cart_item| %>
<%= fields_for "cart_items[]", cart_item do |f| %>
<% @category.items.each do |item| %>
<%= item.name %>
<%= f.hidden_field :item_id, value: item.id %>
<%= f.text_field :qty %>
<% end %>
<%= f.submit %>
<% end %>
<% end %>
<% end %>
def create
@cart_items = params[:cart_items]
@cart_items.each do |c|
@cart_item = CartItem.new(c)
if @cart_item.qty.present?
@cart_item.cart_id = @cart.id
@cart_item.save
end
end
redirect_to :back
end
<%= form_tag cart_items_path do %>
<% @cart_items.each do |cart_item| %>
<%= fields_for "cart_items[]", cart_item do |f| %>
<% @category.items.each do |item| %>
<%= item.name %>
<%= f.hidden_field :item_id, value: item.id %>
<%= f.text_field :qty %>
<% end %>
<%= f.submit %>
<% end %>
<% end %>
<% end %>
class RegistrationsController < Devise::RegistrationsController
def create
build_resource(sign_up_params)
resource_saved = resource.save
yield resource if block_given?
if resource_saved
if resource.posts.present?
post = resource.posts.first
flash[:success] = "Поздравляем Ваше сообщение опубликованно!"
User.includes(:categories, :roles).references(:categories, :roles).where(categories: {id: post.category_id}, roles: { id: 4 }).pluck(:email).each do |email|
PostsMailer.delay.deliver_posts_register(email, post)
end
end
if resource.active_for_authentication?
set_flash_message :notice, :signed_up if is_flashing_format?
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message :notice, :"signed_up_but_#{resource.inactive_message}" if is_flashing_format?
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
@validatable = devise_mapping.validatable?
if @validatable
@minimum_password_length = resource_class.password_length.min
end
respond_with resource
end
end
end
<% if @category.id > 13 %>
<% Category.where(id:params[:category_id]).each do |c| %>
<% Category.where(parent_id:c.parent_id).each do |cc| %>
<ul>
<li>
<div class="pop_task_block">
<%=link_to cc.name, new_category_post_path(cc) %>
</div>
</li>
<% end %>
<% end %>
<% end %>
</ul>