Posts

Showing posts from October, 2021

code test by trainer ::: For Robot

 check and Change the code and test the code by the trainer ........................ robots_controller.rb class RobotsController < ApplicationController   skip_before_action :verify_authenticity_token   def create     @robot = Robot.new(params[:robot])     @robot.execute_commands!     render :new     RobotData.new(params[:robot]).execute_commands!     return render json: @robot.report   end end made file in lib folder :: file of robot data- check the sudo test with app name  class RobotData   include ActiveModel::Model   attr_accessor :size_grid, :max_x, :max_y, :x, :y, :f, :commands, :report   def initialize(params={})     @x = params[:x].try(:to_i)     @y = params[:y].try(:to_i)     @f = params[:f] || ""     @size_grid = sanitize_size(params[:size_grid])     @max_x, @max_y = @size_grid.split('x').map(&:to_i)     @commands = params...

Django ++ Works how it works and installation process also

Official Website :::::::::::::::: djangoproject.com Step 1.  Install Python = How to Install Python 20.04 ubuntu. Step 2.  pip istall  :: in django is just like gem in rails  Step 3.  Django Install by php Step 4. Create Django Application :: Django-admin startproject mysite Step 5 : manage.py  = it works with all server this and run all this. For django which python version will use you can check. sTEP 6 :: python3/manage.py run server  some command to run at times  :: git pull origin master  git checkout .

mongo db and application setup

  install mongo db on ubuntu  https://docs.mongodb.com/manual/tutorial/install-mongodb-on-ubuntu/ ........................................................................................................................... start working application with Rails :: https://docs.mongodb.com/mongoid/current/tutorials/getting-started-rails/

Rspec

 1. https://github.com/rspec/rspec-rails   :: follow thes gem doc 2. factory.rb call karwa dena. 3.

mongo db how to setup

sadhna blog

 https://sadhnasingh642.blogspot.com/search?q=install+ruby

mongodb setup

  development: # Configure available database sessions. (required) sessions: default: uri: 'mongodb://[username]:[password]@ds043497.mongolab.com:43497/[database]' options: consistency: :strong max_retries: 30 retry_interval: 1 timeout: 15 test: sessions: default: database: my_pm_app_test hosts: - localhost:27017 options: read: primary # In the test environment we lower the retries and retry interval to # low amounts for fast failures. max_retries: 1 retry_interval: 0 production: # Configure available database sessions. (required) sessions: default: # The standard MongoDB connection URI allows for easy replica set # connection setup. # Use environment variables or a config file to keep your # credentials safe. uri: 'mongodb://[username]:[password]@ds043497.mongolab.com:43497/[d...

How to check mongo db version and mongo db is installed in your ubuntu or not

mongod --version mongo --version 

Add the thumbnail to the video

 https://github.com/evrone/carrierwave-video-thumbnailer this is the main link from the guides.rubyonrails.org with active storage https://blog.heroku.com/rails-active-storage

What are the Forms in :: Ruby on Rails :: Explain

  Form To create a form tag with the specified action, and with POST request, use the following syntax − <%= form_tag : action => 'update' , : id => @some_object %> <%= form_tag ( { : action => : save , }, { : method => : post }) %> Use :multipart => true to define a MIME-multipart form (for file uploads). <%= form_tag ( {: action => 'upload' }, : multipart => true ) %> File Upload Define a multipart form in your view − <%= form_tag ( { : action => 'upload' }, : multipart => true ) %> Upload file: <%= file_field ( "form" , "file" ) %> <br /> <%= submit_tag ( "Upload file" ) %> <%= end_form_tag %> Handle the upload in the controller − def upload file_field = @params [ 'form' ][ 'file' ] rescue nil # file_field is a StringIO object file_field . content_type # 'text/cs...

Difference :: Main difference between the updown method and change method of the migration

 If change does both, why bother with up and down? In some cases, your migration may require manual changes outside of Rails conventions that change does not support and can’t automatically figure the inverse of.  For example, to manage some of our tables, we have implemented a “soft delete” service change method does not support some of the rails conventions  for example soft delete, so up down method of migration will never fail, change method can fail in some cases.

What is Soft Delete Method in Rails :: What does Soft Delete do in the Rails

Any record where that column has a non- NULL value is considered  to be soft-deleted. When a record is deleted via Active Record (the default ORM library packaged with Ruby on Rails), instead of actually deleting the record from the database, populate the deleted_at column with the time of deletion.

form_for , form_with and form_tag :; Difference

Forms in Rails :::::::::::::::::::: Generally we hav used three basic types of the Forms in Rails form_for :: A utomatically includes the model id as hidden field in the form form_tag :: I t generates a form with the POST method by default form_with :: Function of Rails to generate an HTML form tag .............................................................................................................. form_for :: The #form_for method automatically includes the model id as a hidden field in the form. This is used to maintain the correlation between the form data and its associated model. Some ORM systems do not use IDs on nested models so in this case you want to be able to disable the hidden id. ........................................................................................ form_ with :: form_with is a function that is created by Rails to generate an HTML form tag. It is like a handy shortcut for developers to create forms because forms in web applications are an import...

Upgrading in Rails

 Upgrading in Rails ................................................ Upgrading from any Version of Rails to any other different Version of Rails :: Is Very Important Section :::::::::::::: Read This in details and work on it.

How to Use Link_to Method and f=href Tag :::::::::::::::::::::::::: https://www.rubyguides.com/2019/05/rails-link_to-method/

Image
 https://www.rubyguides.com/2019/05/rails-link_to-method/ ................................................................................................................................... How to Use Rails link_to Method (With Examples) / By  Jesus Castello /  10 COMMENTS Rails  link_to  method! One of the most common helper methods you’ll use in all your Rails applications. But how does it work? If you came here to learn about  link_to  & the different options you can use with it then you’re in the right place! First… What does  link_to  do? Well, this whole website thing only works because we have links between pages. That’s how you go from page to page. In plain HTML, you create a link like this : < a href= "/ruby-book" > Improve Your Ruby Skills < /a > But in Rails that would look like this : Get My Ultimate Ruby Cheatsheet :  This handy 7-page PDF helps you QUICKLY find the Ruby syntax you need, that Ruby method you...