logo
down
shadow

Cannot enter simply form information into SQLite DB (Rails)


Cannot enter simply form information into SQLite DB (Rails)

Content Index :

Cannot enter simply form information into SQLite DB (Rails)
Tag : ruby-on-rails , By : Mariamario
Date : November 23 2020, 01:01 AM

may help you . So, I'm running into a fairly simple problem, where I cannot enter some simple form values into my SQLite DB (Rails). , Edit the plans_controller.rb:-
def create
  #render plain: params[:plan].inspect
  @plan = Plan.new(plan_params)
  if @plan.save
    redirect_to @plan
  else
    redirect_to dashboard_path, :notice => "Plan NOT Created!"
  end
end

private

def plan_params
  params.require(:plan).permit(:name,:type,:user_id)
end
rails g migration rename_fields_in_plans

class RenameFieldsInPlans < ActiveRecord::Migration
  def change
    rename_column :plans, :type, :plan_type
  end
end
rake db:migrate

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How do I transform my search form so that on enter it simply redirects users to what they wrote?


Tag : html , By : MK.
Date : March 29 2020, 07:55 AM
hope this fix your issue I want to transform the searchform so that when an user clicks enter it simply redirects him to http://chusmix.com/text , Use JavaScript.
<form action="http://chusmix.com/" onsubmit="window.location = action + s.value; return false;">
    <input name="s">
    <input type="submit">
</form>

What can I do to keep default text from being submitted in a web form if a user does not enter information?


Tag : javascript , By : lonehunter01
Date : March 29 2020, 07:55 AM
Hope this helps I have a form that asks for First/Last name, email and phone. I don't want to use "placeholder" since IE lacks that ability. I have tried many things but do not know enough about script coding on how I can strip the default text out of the field when someone submits their information. , Here's how I do it on a simple text input. HTML:
<form id="myemailform">
  <input class="text email" type="text" name="email" value="Enter e-mail address"/>
  <input type="submit" value="Submit">
</form
<script src="http://code.jquery.com/jquery-1.8.2.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function() {
    $('input.text').each(function() {
        $.data(this, 'default', this.value);
    }).focus(function() {
        if (!$.data(this, 'edited')) {
            this.value = "";
        }
    }).change(function() {
        $.data(this, 'edited', this.value != "");
    }).blur(function() {
        if (!$.data(this, 'edited')) {
            this.value = $.data(this, 'default');
        }
    });

    $('#myemailform').submit(function() {
        if($(".email").val() == "Enter e-mail address") {$(".email").val("");}
        return true;
    });
});
</script>

Using prepare statement in php form and not logging in when enter information


Tag : php , By : Vijayant Singh
Date : March 29 2020, 07:55 AM
should help you out Taken directly from the PHP website as an example of the sort of data you would be passing in to the function.
password_verify
<?php

    // See the password_hash() example to see where this came from.
    $hash = '$2y$07$BCryptRequires22Chrcte/VlQH0piJtjXl.0t1XkA8pw9dMXTpOq';

    if (password_verify('rasmuslerdorf', $hash)) {
        echo 'Password is valid!';
    } else {
        echo 'Invalid password.';
    }

?>
<?php

    /**
     * We just want to hash our password using the current DEFAULT algorithm.
     * This is presently BCRYPT, and will produce a 60 character result.
     *
     * Beware that DEFAULT may change over time, so you would want to prepare
     * By allowing your storage to expand past 60 characters (255 would be good)
     */
    echo password_hash("rasmuslerdorf", PASSWORD_DEFAULT)."\n";

?>

The above example will output something similar to:

$2y$10$.vGA1O9wmRjrwAVXD98HNOgsNpDczlqm3Jq7KnEd1rVAGv3Fykk1a
if( isset( 
        $_POST['submitlogin'],
        $_POST['usernamelogin'],
        $_POST['passwordlogin']
    ) && !empty( $_POST['usernamelogin'] ) && !empty( $_POST['passwordlogin'] ) ){

    $inUsername=$_POST["usernamelogin"];
    $inPassword=$_POST["passwordlogin"];

    /* select two fields but only use username in where clause */
    $stmt = $con->prepare("select `username`, `password` from `users` where `username` = ?");
    if( $stmt ){

        $stmt->bind_param('s', $inUsername );
        $stmt->execute();

        /* bind the results */
        $stmt->bind_result( $username, $hashed_password );
        $stmt->fetch();
        $stmt->free_result();
        $stmt->close();

        /* use the given password and the returned hashed password - see if they match */
        if( password_verify( $inPasswordDB, $hashed_password ) ){

            $_SESSION['username']=$inUsername;
            header( "location: UserProfile.php" );

        } else {
            echo "<h1>Incorrect username or password</h1>"; 
        }

    } else {
        echo "statement failed";
    }
}

How to enter django form information into the DB


Tag : python , By : Kirks
Date : March 29 2020, 07:55 AM

I need to re-enter my ruby on rails sqlite console so I can do sqlite commands?


Tag : ruby-on-rails , By : James Lupiani
Date : March 29 2020, 07:55 AM
Related Posts Related QUESTIONS :
  • Caching external images with Rails fragment caching
  • Suppress password change email when accepting invitation with Devise Invitable
  • redirect status 301 is not working on heroku
  • How to add foreign key in migration where reference table has no id column
  • Why 'activerecord-import' doesn't perform bulk insert?
  • Setting environment variables in ubuntu production server and Rails
  • rails belongs_to optional but check exists if passed
  • How are parameters sent when I use instance variables in form_for in rails
  • Deploying a Rails App to Multiple Servers using Capistrano - Best Practices
  • Rails Model Relationship: Has one but also belongs to many
  • How to override a render to create a custom "render :my_format => argument" in rails 2.3(.5)?
  • What happened to Builder::XmlMarkup in Rails 3?
  • Rails 3 Beta 2, Haml, Nested Layouts and LocalJumpError
  • Rails Layout name inside view
  • split html text in 2 paragraphs
  • Pass variable from Devise controller to custom mailer?
  • How to pass formdata in swagger with require ruby on rails
  • How can i resolve this- rake:aborted! Mysql2::Error: Access denied for user 'root'@'localhost' (using password: NO)
  • random ActionController::InvalidAuthenticityToken in my rails app
  • How to determine which controller has been called from ApplicationController?
  • Parameterize an ActiveRecord #joins method
  • Why the redis returning more values instead of count?
  • Is this ruby(rails) code readable simply?
  • Can I see what SQL an ActiveRecord .save call would generate, without doing the save?
  • Time.current.tap{|t| t.change hour: 10 } is not working in Rails 4.2
  • Write active decorator DRY
  • Creating 2 Models in Controller Action With Transaction - Rails 4
  • How do I display the text with all of the tabs and new lines (\t and \n) in Ruby on Rails?
  • Why my Module is not being loaded in Rails?
  • how to retrieve data from the database using the has_many association
  • Out of ranger error, Type::Integer during rspec test
  • Generate a video from many images using RMagick in RoR
  • Calling an overriden scope from an included concern in the overriding scope
  • ActionController::UnknownFormat on Bugsnag
  • How do I pass a person object into a related Post model object
  • rubocop cannot load such file -- rubocop-rails
  • Malicious Bots waking up heroku free app and using up all dyno hours
  • How to do RSpec of validators?
  • Is there a way to wrap the response of all controller methods in a json object in application_controller.rb?
  • Need to implement #cache! if you want to use Cloudinary::CarrierWave::Storage as a cache storage
  • How to integrate custom bootstrap theme in activeadmin
  • How can I load an STI record using just the base STI class?
  • Getting the .each loop result with the lowest number from json
  • When and where to aggregate or perform calculations on data in RESTful Rails API
  • How do you write a conditional ternary operator inline in Ruby on Rails?
  • Why put require statement at the end of a ruby file?
  • In Rails, is it possible to display an alert without calling redirect_to or render?
  • Convert hash of hash in array of hash
  • Rails 5 tries to save the empty string as nil
  • websocket-driver was not found on deploy
  • Dangerous query method deprecation warning on Rails 5.2.3
  • Using ERB in Markdown with Redcarpet
  • How to create list of unique array items from thousands of records in Rails?
  • Undefined method 'suspend_paypal' for User
  • Any good methods to find Ruby on Rails memory leak?
  • Why does if __FILE__ == $0 not work on Heroku with Rails 5.2?
  • Rails: How to implement login and authentication where i have five different user models in rails?
  • What is the impact of changing rails secret_key_base on production?
  • how to keep heroku dyno worker alive if web dyno goes to sleep?
  • syntax error, unexpected end-of-input, expecting keyword_end. when running rspec of feature file
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com