質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
dBASE

dBASEは、Ashton Tate社が開発したデータベース管理システム (DBMS) です。初期のマイクロコンピュータ向けに開発。広く使用されていました。現在は、RAD環境を取り入れたVisual dBASEとして、米dBASE社が提供しています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

Q&A

1回答

1142閲覧

Rails ボタンがcreateではなくsubmitと表示されてしまい、更新されない。

masaosan18

総合スコア64

dBASE

dBASEは、Ashton Tate社が開発したデータベース管理システム (DBMS) です。初期のマイクロコンピュータ向けに開発。広く使用されていました。現在は、RAD環境を取り入れたVisual dBASEとして、米dBASE社が提供しています。

Ruby

Rubyはプログラミング言語のひとつで、オープンソース、オブジェクト指向のプログラミング開発に対応しています。

Ruby on Rails 6

Ruby on Rails 6は、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Sass

Sassは、プログラミング風のコードでCSSを生成できるスタイルシート言語です。 scss ファイルを、変換(コンパイル)してCSSファイルを作成します。

0グッド

0クリップ

投稿2020/07/10 14:43

Railsアプリを作成しています。

プロフィール変更画面を作成しているのですが、ボタン(Create)を押すとプロフィールが更新されるようにしたいのですが、そのボタンの表示がsubmitというものになってしまいます。

これの変更方法がわかりません。どなたか助けてください。

routes

1Rails.application.routes.draw do 2 devise_for :users 3 resources :posts 4 resources :profiles, only: [:show, :new, :edit, :create, :update] 5 root 'welcome#index' 6end 7
#profiles/new.html.erb <div> <h1>プロフィールを作成しましょう!</h1> <%= render 'form' %> </div>
#profiles/_form.html.erb <%= form_with model: @post, local: true do |f| %> <div class="form-group"> <%= f.label :name, "ニックネーム" %> <%= f.text_field :name %> </div> <div class="form-group"> <%= f.label :learning_history, "学習歴(年)" %> <%= f.number_field :learning_history %> </div> <div class="form-group"> <%= f.label :purpose, "Ruby on Rails学習の目的" %> <%= f.text_field :purpose %> </div> <div class="form-group"> <%= f.label :image, "プロフィール画像" %> <%= f.file_field :image %> </div> <div class="submit-block"> <%= f.submit class: "button" %> </div> <% end %>

controller

1class ProfilesController < ApplicationController 2 before_action :authenticate_user! 3 before_action :find_profile, only: [:show, :edit, :update] 4 5 def show 6 end 7 8 def new 9 return redirect_to edit_profile_path(current_user.profile) if current_user.profile.present? 10 @profile = Profile.new 11 end 12 13 def edit 14 end 15 16 def create 17 @profile.user = current_user 18 @profile = Profile.new(profile_params) 19 if @profile.save! 20 redirect_to root_path, notice: "プロフィール情報の登録が完了しました" 21 else 22 render :new 23 end 24 end 25 26 def update 27 if @profile.update(profile_params) 28 redirect_to root_path, notice: "プロフィール情報の更新が完了しました" 29 else 30 render :edit 31 end 32 end 33 34 def destroy 35 end 36 37 private 38 39 def find_profile 40 @profile = Profile.find(params[:id]) 41 end 42 43 def profile_params 44 params.require(:profile).permit( 45 :name, :learning_history, :purpose, :image 46 ) 47 end 48end 49

scss

1// Place all the styles related to the profiles controller here. 2// They will automatically be included in application.css. 3// You can use Sass (SCSS) here: http://sass-lang.com/ 4 5#profiles-new, #profiles-edit, #profiles-create, #profiles-update { 6 form { 7 .form-group { 8 margin: 10px 0; 9 10 label { 11 margin-bottom: 5px; 12 display: block; 13 } 14 15 input[type="text"], input[type="number"] { 16 width: 100%; 17 padding: 5px; 18 border-radius: 5px; 19 border: 1px solid #ccc; 20 appearance: none; 21 -webkit-appearance: none; 22 -moz-appearance: none; 23 } 24 } 25 .submit-block { 26 display: flex; 27 align-items: center; 28 justify-content: center; 29 margin:15px 0; 30 } 31 .button { 32 display : inline-block; 33 border-radius : 5%; /* 角丸 */ 34 font-size : 18pt; /* 文字サイズ */ 35 text-align : center; /* 文字位置 */ 36 cursor : pointer; /* カーソル */ 37 padding : 12px 12px; /* 余白 */ 38 background : #333; /* 背景色 */ 39 color : #ffffff; /* 文字色 */ 40 line-height : 1em; /* 1行の高さ */ 41 transition : .3s; /* なめらか変化 */ 42 box-shadow : 6px 6px 3px #666666; /* 影の設定 */ 43 border : 2px solid #333; /* 枠の指定 */ 44 } 45 .button:hover { 46 box-shadow : none; /* カーソル時の影消去 */ 47 color : #333; /* 背景色 */ 48 background : #ffffff; /* 文字色 */ 49 } 50 } 51}

宜しくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

profiles/_form.html.erbの送信ボタン部分を以下のように書き換えてみてください

<%= f.submit 'Create', class: "button" %>

投稿2020/07/10 20:13

mottox2

総合スコア299

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

masaosan18

2020/07/11 00:04

ありがとうございます。 Createの表示にすることはできましたが、No route matches [POST] "/profiles/new"とルーティングのエラーが出てしまいます。
no1knows

2020/07/11 07:32

<%= form_with model: @post, local: true do |f| %>をprofileにしてください。
masaosan18

2020/07/11 13:52

ありがとうございます!解決しました!
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだベストアンサーが選ばれていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問