Permalink
Browse files

add basic form

  • Loading branch information...
oblakeerickson committed Aug 30, 2018
1 parent a2800d5 commit 14b17f804f68732bd9544c358766508e8abf68e7
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
@@ -0,0 +1,3 @@
// Place all the styles related to the Links controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
@@ -0,0 +1,17 @@
class LinksController < ApplicationController
def new
@link = Link.new
end

def create
@link = Link.new(link_params)
puts @link.url
redirect_to :action => 'new'
end

private

def link_params
params.require(:link).permit(:url)
end
end
@@ -0,0 +1,2 @@
module LinksHelper
end
@@ -0,0 +1,6 @@
class Link
include ActiveModel::Model

attr_accessor :url
validates :url, presence: true
end
@@ -0,0 +1,2 @@
<h1>Links#create</h1>
<p>Find me in app/views/links/create.html.erb</p>
@@ -0,0 +1,9 @@
<h1>Paste YouTube video link below</h1>

<%= form_for(@link) do |f| %>
<p>
<%= f.text_field :url %>
</p>

<%= f.submit "Submit" %>
<% end %>
@@ -1,3 +1,4 @@
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
root to: redirect('/links/new')
resources 'links', :only => [:new, :create]
end
@@ -0,0 +1,9 @@
require 'test_helper'

class LinksControllerTest < ActionDispatch::IntegrationTest
test "should get create" do
get links_create_url
assert_response :success
end

end

0 comments on commit 14b17f8

Please sign in to comment.