AnsweredAssumed Answered

Failed to create simple CRUD

Question asked by Juan Guerrero on Oct 4, 2018
Latest reply on Oct 4, 2018 by Robert Carroll

Hi all,

 

I'm trying to create a new model (called Logo) within Canvas LMS. Everithing looks good, but the pages shows a left Canvas menu and an error 500 text.

 

> rails generate controller Logos                             // OK

> rails generate model Logo name:string url:text    // OK

>rake db:migrate>tagged[predeploy]                      // OK

 

My files are:

 

---------- logos_controller.rb ---------- 
class LogosController < ApplicationController
  def index
    @logos = Logo.all
  end

 

  def show
    @logs = Logo.find(params[:id])
  end

 

  def new
  end

 

  def create
    @logo = Logo.new(params.require(:logo).permit(:name, :url))
    @logo.save
    redirect_to @logo
  end
private
  def logo_params
    params.require(:logo).permit(:name, :url)
  end

 

end
---------- index.html.erb ---------- 
<h1>Listing Logos</h1>
<%= link_to 'New Logo', new_logo_path %>
<table>
  <tr>
    <th>Name</th>
    <th>URL</th>
    <th></th>
  </tr>

 

 

  <% @logos.each do |logo| %>
    <tr>
      <td><%= logo.name %> </td>
      <td><%= logo.url %> </td>
      <td><%= link_to 'show', logo_path(logo) %> </td>
    </tr>
    <% end %>
  </table>
  ---------- new.html.erb ---------- 
<%= form_with scope: :logo, url: logos_path, local: true do |form| %>
<p>
  <%= form.label :name %><br>
  <%= form.text_field :name %>
</p>

 

<p>
<%= form.label :url %><br>
<%= form.text_area :url %>
</p>

 

  <p>
    <%= form.submit %>
  </p>
  <% end %>
  <%= link_to 'Back', logos_path %>
----------  show.html.erb ---------- 
<p>
  <strong>Name:</strong>
  <%= @logo.name %>
</p>

 

<p>
  <strong>URL:</strong>
  <%= @logo.url %>
</p>

 

<%= link_to 'Back', logos_path %>
routes.rb
...
resources :logos
...

 

Can i exclude this CRUD from the "canvas interceptor"?

Attachments

Outcomes