-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from pawanghising67/newfunc
Edit and update action
- Loading branch information
Showing
25 changed files
with
223 additions
and
46 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the apartmentsws controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
class ApartmentswsController < ApplicationController | ||
before_action :set_apartmentsw, only: [:show, :edit, :update, :destroy] | ||
|
||
# GET /apartmentsws | ||
# GET /apartmentsws.json | ||
def index | ||
@apartmentsws = Apartmentsw.all | ||
end | ||
|
||
# GET /apartmentsws/1 | ||
# GET /apartmentsws/1.json | ||
def show | ||
end | ||
|
||
# GET /apartmentsws/new | ||
def new | ||
@apartmentsw = Apartmentsw.new | ||
end | ||
|
||
# GET /apartmentsws/1/edit | ||
def edit | ||
end | ||
|
||
# POST /apartmentsws | ||
# POST /apartmentsws.json | ||
def create | ||
@apartmentsw = Apartmentsw.new(apartmentsw_params) | ||
|
||
respond_to do |format| | ||
if @apartmentsw.save | ||
format.html { redirect_to @apartmentsw, notice: 'Apartmentsw was successfully created.' } | ||
format.json { render :show, status: :created, location: @apartmentsw } | ||
else | ||
format.html { render :new } | ||
format.json { render json: @apartmentsw.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PATCH/PUT /apartmentsws/1 | ||
# PATCH/PUT /apartmentsws/1.json | ||
def update | ||
respond_to do |format| | ||
if @apartmentsw.update(apartmentsw_params) | ||
format.html { redirect_to @apartmentsw, notice: 'Apartmentsw was successfully updated.' } | ||
format.json { render :show, status: :ok, location: @apartmentsw } | ||
else | ||
format.html { render :edit } | ||
format.json { render json: @apartmentsw.errors, status: :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /apartmentsws/1 | ||
# DELETE /apartmentsws/1.json | ||
def destroy | ||
@apartmentsw.destroy | ||
respond_to do |format| | ||
format.html { redirect_to apartmentsws_url, notice: 'Apartmentsw was successfully destroyed.' } | ||
format.json { head :no_content } | ||
end | ||
end | ||
|
||
private | ||
# Use callbacks to share common setup or constraints between actions. | ||
def set_apartmentsw | ||
@apartmentsw = Apartmentsw.find(params[:id]) | ||
end | ||
|
||
# Never trust parameters from the scary internet, only allow the white list through. | ||
def apartmentsw_params | ||
params.require(:apartmentsw).permit(:title, :body, :user_id) | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
class PostsController < ApplicationController | ||
|
||
def homepage | ||
|
||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module ApartmentswsHelper | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
class Apartmentsw < ActiveRecord::Base | ||
belongs_to :user | ||
end |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
json.extract! apartmentsw, :id, :title, :body, :, :user_id, :created_at, :updated_at | ||
json.url apartmentsw_url(apartmentsw, format: :json) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<%= form_for(@apartmentsw) do |f| %> | ||
<% if @apartmentsw.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@apartmentsw.errors.count, "error") %> prohibited this apartmentsw from being saved:</h2> | ||
|
||
<ul> | ||
<% @apartmentsw.errors.full_messages.each do |message| %> | ||
<li><%= message %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :title %><br> | ||
<%= f.text_field :title %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :body %><br> | ||
<%= f.text_field :body %> | ||
</div> | ||
|
||
<div class="field"> | ||
<%= f.label :user_id %><br> | ||
<%= f.text_field :user_id %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing Apartmentsw</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @apartmentsw %> | | ||
<%= link_to 'Back', apartmentsws_path %> |
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<h1>Listing Apartmentsws</h1> | ||
|
||
<table> | ||
<thead> | ||
<tr> | ||
<th>Title</th> | ||
<th>Body</th> | ||
<th></th> | ||
<th>User</th> | ||
<th colspan="3"></th> | ||
</tr> | ||
</thead> | ||
|
||
<tbody> | ||
<% @apartmentsws.each do |apartmentsw| %> | ||
<tr> | ||
<td><%= apartmentsw.title %></td> | ||
<td><%= apartmentsw.body %></td> | ||
|
||
<td><%= apartmentsw.user %></td> | ||
<td><%= link_to 'Show', apartmentsw %></td> | ||
|
||
|
||
<td><%= link_to 'Edit', edit_apartmentsw_path(apartmentsw) %></td> | ||
|
||
|
||
<td><%= link_to 'Destroy', apartmentsw, method: :delete, data: { confirm: 'Are you sure?' } %></td> | ||
|
||
</tr> | ||
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<br> | ||
|
||
<%= link_to 'New Apartmentsw', new_apartmentsw_path %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.array! @apartmentsws, partial: 'apartmentsws/apartmentsw', as: :apartmentsw |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New Apartmentsw</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', apartmentsws_path %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<strong>Title:</strong> | ||
<%= @apartmentsw.title %> | ||
</p> | ||
|
||
<p> | ||
<strong>Body:</strong> | ||
<%= @apartmentsw.body %> | ||
</p> | ||
|
||
|
||
|
||
<p> | ||
<strong>User:</strong> | ||
<%= @apartmentsw.user%> | ||
</p> | ||
|
||
<%= link_to 'Edit', edit_apartmentsw_path(@apartmentsw) %> | | ||
<%= link_to 'Back', apartmentsws_path %> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
json.partial! "apartmentsws/apartmentsw", apartmentsw: @apartmentsw |
Empty file.
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class CreateApartmentsws < ActiveRecord::Migration | ||
def change | ||
create_table :apartmentsws do |t| | ||
t.text :title | ||
t.string :body | ||
|
||
t.references :user, index: true, foreign_key: true | ||
|
||
t.timestamps null: false | ||
end | ||
end | ||
end |
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