「Ruby rails」の版間の差分
提供: wikipokpok
(同じ利用者による、間の20版が非表示) | |||
1行目: | 1行目: | ||
[[category:memo|{{PAGENAME}}]] | [[category:memo|{{PAGENAME}}]] | ||
− | gemのインストール先 例えばbootstrap 環境によって違う | + | == いろいろ == |
+ | rails routes | ||
+ | Model.where(conditions).exists? | ||
+ | flash.[:alert] = 'メッセージを入力してください。' | ||
+ | flash.now[:alert] = 'メッセージを入力してください。' | ||
+ | |||
+ | == Rails 6にjQueryとBootstrapを入れる == | ||
+ | == update == | ||
+ | brew upgrade ruby-build | ||
+ | rbenv install -l | ||
+ | rbenv install 3.0.0 | ||
+ | rbenv local 3.0.0 | ||
+ | |||
+ | == バージョン確認 == | ||
+ | rbenv versions | ||
+ | ruby -v | ||
+ | gem -v | ||
+ | rails -v | ||
+ | psql -v | ||
+ | heroku --version | ||
+ | git --version | ||
+ | |||
+ | == vimgrepの使い方 == | ||
+ | ディレクトリを再帰的に検索 | ||
+ | :vim 検索文字 app/** | cw | ||
+ | :vim 検索文字 app/controller/** | cw | ||
+ | カレントバッファを対象にする | ||
+ | :vim 検索文字 % | ||
+ | |||
+ | == NERDTreeの使い方 == | ||
+ | [[NERDTreeの使い方]] | ||
+ | == Homebrewのインストール rbenvのインストール == | ||
+ | https://qiita.com/kaumino/items/726e8436d7e960ca39f9 | ||
+ | |||
+ | == gemのインストール先 例えばbootstrap 環境によって違う == | ||
~/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootstrap-sass-3.4.1/assets/stylesheets/bootstrap | ~/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootstrap-sass-3.4.1/assets/stylesheets/bootstrap | ||
− | Node.jsのインストール | + | == Node.jsのインストール == |
brew install nodebrew | brew install nodebrew | ||
36行目: | 70行目: | ||
v14.4.0 | v14.4.0 | ||
− | + | == vim-plug == | |
+ | .vimrc | ||
Plug 'neoclide/coc.nvim', {'branch': 'release'} | Plug 'neoclide/coc.nvim', {'branch': 'release'} | ||
− | + | インストール | |
:PlugInstall | :PlugInstall | ||
:CocInstall coc-solargraph | :CocInstall coc-solargraph | ||
Installed extension coc-solargraph@1.1.6 at /Users/jq/.config/coc/extensions/node_modules/coc-solargraph | Installed extension coc-solargraph@1.1.6 at /Users/jq/.config/coc/extensions/node_modules/coc-solargraph | ||
+ | |||
+ | touch ~/.vim/coc-settings.json | ||
+ | |||
+ | { | ||
+ | "languageserver": { | ||
+ | "sorbet": { | ||
+ | "command": "srb", | ||
+ | "args": ["tc", "--typed", "true", "--enable-all-experimental-lsp-features", "--lsp", "--disable-watchman", "--dir", "."], | ||
+ | "filetypes": ["ruby"], | ||
+ | "rootPatterns": ["sorbet/config"], | ||
+ | "initializationOptions": {}, | ||
+ | "settings": {} | ||
+ | } | ||
+ | } | ||
+ | } | ||
Solargraph gem not found. Run `gem install solargraph` or update your Gemfile., Install Now? (y/n) | Solargraph gem not found. Run `gem install solargraph` or update your Gemfile., Install Now? (y/n) | ||
− | + | gem install solargraph | |
+ | |||
+ | == rails postgres == | ||
rails _6.0.3_ new tepnote -d postgresql | rails _6.0.3_ new tepnote -d postgresql | ||
+ | |||
+ | == 表示切り替え == | ||
+ | <div class="form-group"> | ||
+ | <label class="control-label" for="search"></label> | ||
+ | <select class="form-control" name="search"> | ||
+ | <option value="">何を検索しますか?</option> | ||
+ | <option value="house_notes">家備考</option> | ||
+ | <option value="personal_notes">個人備考</option> | ||
+ | </select> | ||
+ | </div> | ||
+ | |||
+ | <p id="house_notes" style="display: none;"> | ||
+ | <%= form_tag(search_user_path, :method => 'get') do %> | ||
+ | <%= select_tag(:option, options_for_select([["user", "1"],["post","2"]]))%> | ||
+ | <%= text_field_tag :search %> | ||
+ | <%= submit_tag 'Search' %> | ||
+ | <% end %> | ||
+ | <p id="personal_notes" style="display: none;"> | ||
+ | <input type="text" name="writer" value="1" size="20" maxlength="20"> | ||
+ | </p> | ||
+ | |||
+ | <script type="text/javascript"> | ||
+ | $(function(){ | ||
+ | $('select[name="search"]').change(function() { | ||
+ | if ($('select[name="search"] option:selected').val() == 'house_notes') | ||
+ | $('#house_notes').css('display','block'); | ||
+ | else | ||
+ | $('#house_notes').css('display','none'); | ||
+ | |||
+ | if ($('select[name="search"] option:selected').val() == 'personal_notes') | ||
+ | $('#personal_notes').css('display','block'); | ||
+ | else | ||
+ | $('#personal_notes').css('display','none'); | ||
+ | }); | ||
+ | }); | ||
+ | </script> |
2021年2月2日 (火) 11:23時点における最新版
目次
いろいろ[編集]
rails routes Model.where(conditions).exists? flash.[:alert] = 'メッセージを入力してください。' flash.now[:alert] = 'メッセージを入力してください。'
Rails 6にjQueryとBootstrapを入れる[編集]
update[編集]
brew upgrade ruby-build rbenv install -l rbenv install 3.0.0 rbenv local 3.0.0
バージョン確認[編集]
rbenv versions ruby -v gem -v rails -v psql -v heroku --version git --version
vimgrepの使い方[編集]
ディレクトリを再帰的に検索
:vim 検索文字 app/** | cw :vim 検索文字 app/controller/** | cw
カレントバッファを対象にする
:vim 検索文字 %
NERDTreeの使い方[編集]
Homebrewのインストール rbenvのインストール[編集]
https://qiita.com/kaumino/items/726e8436d7e960ca39f9
gemのインストール先 例えばbootstrap 環境によって違う[編集]
~/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/gems/bootstrap-sass-3.4.1/assets/stylesheets/bootstrap
Node.jsのインストール[編集]
brew install nodebrew
nodebrew -v nodebrew 1.0.1 Example: # install nodebrew install v8.9.4 # use a specific version number nodebrew use v8.9.4
mkdir -p ~/.nodebrew/src
nodebrew install stable
nodebrew ls v14.4.0 current: none
nodebrew use 14.4.0 use v14.4.0
nodebrew ls v14.4.0 current: v14.4.0
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zprofile
source ~/.zprofile
node -v v14.4.0
vim-plug[編集]
.vimrc
Plug 'neoclide/coc.nvim', {'branch': 'release'}
インストール
:PlugInstall
:CocInstall coc-solargraph Installed extension coc-solargraph@1.1.6 at /Users/jq/.config/coc/extensions/node_modules/coc-solargraph
touch ~/.vim/coc-settings.json
{ "languageserver": { "sorbet": { "command": "srb", "args": ["tc", "--typed", "true", "--enable-all-experimental-lsp-features", "--lsp", "--disable-watchman", "--dir", "."], "filetypes": ["ruby"], "rootPatterns": ["sorbet/config"], "initializationOptions": {}, "settings": {} } } }
Solargraph gem not found. Run `gem install solargraph` or update your Gemfile., Install Now? (y/n)
gem install solargraph
rails postgres[編集]
rails _6.0.3_ new tepnote -d postgresql
表示切り替え[編集]
<label class="control-label" for="search"></label> <select class="form-control" name="search"> <option value="">何を検索しますか?</option> <option value="house_notes">家備考</option> <option value="personal_notes">個人備考</option> </select>
<script type="text/javascript"> $(function(){
$('select[name="search"]').change(function() { if ($('select[name="search"] option:selected').val() == 'house_notes') $('#house_notes').css('display','block'); else $('#house_notes').css('display','none');
if ($('select[name="search"] option:selected').val() == 'personal_notes') $('#personal_notes').css('display','block'); else $('#personal_notes').css('display','none'); });
}); </script>