一个半月后回头看学编程

今天重新看了一个半月前在logdown上写的blog,再看了看小伙伴们写的blog,发觉自己真的没有用心去做事情,也没有真正把时间用在刀刃上,没有用心去学编程,白白浪费了许多的时间,这次我是必须要留级来认真重新学编程了,即使在过去的一个半月中,我学到了很多好东西,但是确实是没有精通,很多编程的基础还没有熟练,今天开始,我要每天在简书上markdown下我的日记,坚持每天学习编程。

今天重新看了一次首个课程,也就是rails new first_app这个课程,这次是用atom打开来看的,这次的打开让我如梦初醒,很多在rails101里面的代码其实rails new first_app中是有的,只不过我在学习了之后的课程后,很多东西是已经懂了,但是我还是不够熟悉,也就是说很多东西我只是知道了一点点,但除了课程以外我没有继续去查询资料和用用心学习,作业也没有很用心地去完成,因此我只能说要认真地再来学一遍,这是对我自己没有认真学的一个惩罚,也是对我自己的鞭策。

下面是rails new first_app中的代码:

class TopicsController < ApplicationController

before_action :set_topic, only: [:show, :edit, :update, :destroy]

# GET /topics

# GET /topics.json

def index

@topics = Topic.all

end

# GET /topics/1

# GET /topics/1.json

def show

end

# GET /topics/new

def new

@topic = Topic.new

end

# GET /topics/1/edit

def edit

end

# POST /topics

# POST /topics.json

def create

@topic = Topic.new(topic_params)

respond_to do |format|

if @topic.save

format.html { redirect_to @topic, notice: 'Topic was successfully created.' }

format.json { render :show, status: :created, location: @topic }

else

format.html { render :new }

format.json { render json: @topic.errors, status: :unprocessable_entity }

end

end

end

# PATCH/PUT /topics/1

# PATCH/PUT /topics/1.json

def update

respond_to do |format|

if @topic.update(topic_params)

format.html { redirect_to @topic, notice: 'Topic was successfully updated.' }

format.json { render :show, status: :ok, location: @topic }

else

format.html { render :edit }

format.json { render json: @topic.errors, status: :unprocessable_entity }

end

end

end

# DELETE /topics/1

# DELETE /topics/1.json

def destroy

@topic.destroy

respond_to do |format|

format.html { redirect_to topics_url, notice: 'Topic was successfully destroyed.' }

format.json { head :no_content }

end

end

private

# Use callbacks to share common setup or constraints between actions.

def set_topic

@topic = Topic.find(params[:id])

end

# Never trust parameters from the scary internet, only allow the white list through.

def topic_params

params.require(:topic).permit(:title, :description, :comment)

end

end

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Spring Cloud为开发人员提供了快速构建分布式系统中一些常见模式的工具(例如配置管理,服务发现,断路器,智...
    卡卡罗2017阅读 134,859评论 18 139
  • Correctness AdapterViewChildren Summary: AdapterViews can...
    MarcusMa阅读 8,900评论 0 6
  • 打了一天电话,没有一个意向客户,整个带着耳机,耳朵里响了一天,徒劳无功,机械重复着同样的话,很累,属于我的路究竟在何方?
    超级英雄悟空阅读 112评论 0 0
  • 发现一个有意思的事,一起共事的同事在岗时大家关系融洽,朋友圈点赞留言互动也不错,但往往离职时会第一时间屏蔽老同事微...
    饮冰室阅读 571评论 0 1