레이블이 Ruby인 게시물을 표시합니다. 모든 게시물 표시
레이블이 Ruby인 게시물을 표시합니다. 모든 게시물 표시

2018년 3월 5일 월요일

Ruby 50 가지 팁 링크

https://gist.github.com/nacyot/7624036

알아두면 도움이 되는 55가지 루비 기법

루비도 공부했으니. 나중에 루비 쓸때 참고

2017년 10월 3일 화요일

루비와 레일스 웹서비스

http://rorlab.org/websites

2017년 9월 28일 목요일

aws 에 ruby on rail 세팅하기

http://psygotsky.blogspot.jp/2017/03/aws-ruby-on-rails.html

2017년 9월 26일 화요일

알아두면 도움이 되는 55가지 루비 기법

https://gist.github.com/nacyot/7624036

Ruby On Rails - Tip and Trick

https://www.slideshare.net/Scudelletti/ruby-tips-andtricks

ruby style guide 관련

루비 스타일 가이드 : https://github.com/bbatsov/ruby-style-guide

에어비엔비의 스타일 가이드 :  https://github.com/airbnb/ruby#whitespace

루비스타일가이드 분석 http://batsov.com/rubocop/

Ruby On Rails - Cloud9 에서 테스트 개발 해보기

http://blog.naver.com/PostView.nhn?blogId=dg_667&logNo=220616006452&parentCategoryNo=&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView

여기에 있는 것처럼 Cloud9 에 가입해서 루비온레일즈 로 게시판을 만들어 보았다.

비지니스 로직이 들어갈 모델관련 파일은
rails g model 모델명  라는 식으로 생성한다.
그러면 db/migrate/ 밑에 테이블 정의하는
t.string:cell2
t.text:comment
처럼 추가한다.
그리고 나서
rake db:migrate 를 실행해서 실제 디비에 테이블이 생성되도록한다.

이제 게시판의 글목록,쓰기,보기,삭제 등을 구현해야 하는데,
일단
http://blog.naver.com/PostView.nhn?blogId=dg_667&logNo=220638145196&parentCategoryNo=&categoryNo=&viewDate=&isShowPopularPosts=false&from=postView

이곳을 참고하여 본다.

현재 board_controller.rb 의 write,list,view,list, delete 메소드(def)에 아무것도 없는데 각각 채워넣어주면된다.

def list
    @table1 = Table1.all
end
하고
list.html.erb에선
<%@table1.each do |tablecell|%>
<p><%=tablecell.cell1%></p>
<%end%>
하면 출력끝..오...

등록은

  def register
    if params[:cell1].present? && params[:cell2].present?
      table1 = Table1.new
      table1.cell1 = params[:cell1]
      table1.cell2 = params[:cell2]
      table1.save
    else
      puts "no data"
    end
    redirect_to action:"list"
  end

function 을...왜 def 로 했을까...

def sipal(num1, num2)
  return num1 + num2
end

이나..

 function sipal(num1, num2)
  return num1 + num2
end

 이나...

좋은지 모르겠음..

Ruby On Rails - 기초 설정

일단 앱의 configure 폴더에
environments , initializers , locale , database  등의 설정파일과 폴더가 있다.

환경은 개발, 배포, 테스트 버젼으로 각각 설정할수 있다.

http://guides.rorlab.org/configuring.html 참고

기본 예약어 등은 http://gnuteam.tistory.com/118 여기서.

Ruby On Rails 를 알아보자 - 개요



루비 온 레일즈를 알아보기 전에 공식 사이트의 설명을 보자
http://rubykr.github.io/rails_guides/getting_started.html

레일즈는 루비 언어로 작성된 웹 어플리케이션 프레임워크 
철학
-DRY – “Don’t Repeat Yourself (반복하지 말 것)”
-CoC , Convention Over Configuration
-REST

MVC 아키텍쳐 기반임

프로젝트 생성 

콘트롤러 생성 :  $ rails generate controller boardController write list ...
콘트롤러생성후 라우터에 콘트롤러가 있다는 것을 지정
config/routes.rb
root :to => "home#index"

일반적인 게시판 류는 그냥 스캐폴드 로 생성

$ rails generate scaffold Post name:string title:string content:text
15개(헉)개의 파일이 생성됨
파일목적
db/migrate/20100207214725_create_posts.rb데이터베이스에 ‘posts’ 테이블 생성하는 마이그레이션 (여러분의 파일 이름은, 다른 타임 스템프 값을 가지고 있습니다.)
app/models/post.rbPost 모델
test/fixtures/posts.yml테스트를 위한 더미(Dummy) posts
app/controllers/posts_controller.rbPosts 컨트롤러
app/views/posts/index.html.erb모든 posts 를 출력하는 index 뷰
app/views/posts/edit.html.erb존재하는 post 를 수정하는 edit 뷰
app/views/posts/show.html.erb단일 post를 보여주는 show 뷰
app/views/posts/new.html.erb새로운 post 를 만들기 위한 new 뷰
app/views/posts/_form.html.erbpost 를 수정하거나 새로 만드는데 사용되는 폼(form)을 저장하는 조각(partial) 파일
app/helpers/posts_helper.rbpost 뷰를 위한 헬퍼(Helper) 함수를 위한 파일
test/unit/post_test.rbposts 모델을 위한 유닛 테스트 파일
test/functional/posts_controller_test.rbposts 컨트롤러를 위한 기능 테스트 파일
test/unit/helpers/posts_helper_test.rbposts 헬퍼(Helper)를 위한 유닛 테스트 파일
config/routes.rbposts 를 위한 라우팅 정보를 담은 수정된 라우팅 파일
public/stylesheets/scaffold.css발판(Scaffold) 뷰를 좀 더 미려하게 만드는 CSS파일
그래..어차피 만들 파일들 미리 만들어 놓고 하나씩 삭제하는것도..