Last active
December 30, 2015 17:29
-
-
Save JRizzle88/7861628 to your computer and use it in GitHub Desktop.
studio No route matches [POST] "/studios/new" , trying to just create a new studio from a button_to with new_studio_path IN the products/index view. I have the Model empty
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## PRODUCTS VIEW ## | |
<%= button_to 'Customize', new_studio_path, :class => 'button [tiny small large] middle pos-10-top' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Verone::Application.routes.draw do | |
devise_for :users, :controllers => {:registrations => "registrations"} | |
devise_for :admins | |
get '/token' => 'home#token', as: :token | |
namespace :admin do | |
get 'dashboard' => 'dashboard#index' | |
root :to => "dashboard#index" | |
resources :admin | |
resources :posts | |
resources :products | |
resources :users | |
resources :orders | |
resources :studios | |
resources :post_categories | |
resources :product_categories | |
end | |
root :to => "home#index" | |
resources :posts do | |
resources :comments | |
end | |
get "/store/index" | |
resources :products | |
resources :line_items | |
resources :orders | |
resources :carts | |
resources :studios | |
resources :post_categories | |
resources :product_categories | |
resources :list_items | |
resources :stores, as: 'store' | |
#get "/store/index" | |
end | |
######ROUTES RESULTS####### | |
studios_path GET /studios(.:format) studios#index | |
POST /studios(.:format) studios#create | |
new_studio_path GET /studios/new(.:format) studios#new | |
edit_studio_path GET /studios/:id/edit(.:format) studios#edit | |
studio_path GET /studios/:id(.:format) studios#show | |
PATCH /studios/:id(.:format) studios#update | |
PUT /studios/:id(.:format) studios#update | |
DELETE /studios/:id(.:format) studios#destroy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StudiosController < ApplicationController | |
before_action :set_studio | |
before_action :studio_params | |
# GET /studios | |
# GET /studios.json | |
def index | |
@studios = Studio.all | |
end | |
# GET /studios/1 | |
# GET /studios/1.json | |
def show | |
@studio = Studio.find(studio_params) | |
end | |
# GET /studios/new | |
def new | |
@studio = Studio.new(params[:id]) | |
end | |
# GET /studios/1/edit | |
def edit | |
end | |
# POST /studios | |
# POST /studios.json | |
def create | |
@studio = Studio.new(studio_params) | |
respond_to do |format| | |
if @studio.save | |
format.html { redirect_to @studio, notice: 'Studio was successfully created.' } | |
format.json { render action: 'show', status: :created, location: @studio } | |
else | |
format.html { render action: 'new' } | |
format.json { render json: @studio.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# PATCH/PUT /studios/1 | |
# PATCH/PUT /studios/1.json | |
def update | |
respond_to do |format| | |
if @studio.update(studio_params) | |
format.html { redirect_to @studio, notice: 'Studio was successfully updated.' } | |
format.json { head :no_content } | |
else | |
format.html { render action: 'edit' } | |
format.json { render json: @studio.errors, status: :unprocessable_entity } | |
end | |
end | |
end | |
# DELETE /studios/1 | |
# DELETE /studios/1.json | |
def destroy | |
@studio.destroy | |
respond_to do |format| | |
format.html { redirect_to studios_url } | |
format.json { head :no_content } | |
end | |
end | |
private | |
# Use callbacks to share common setup or constraints between actions. | |
def set_studio | |
@studio = Studio.find(params[:id]) | |
end | |
# Never trust parameters from the scary internet, only allow the white list through. | |
def studio_params | |
params.require(:studio).permit(:name) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment