title: How to save data using Model in Magento2
body: <p>I have a basic module ready with controller and view working perfectly. Now, I am trying to initiate model in order to save data using custom model in table containing attributes (question Title, Question). Basically, what steps I should proceed in order to save data through model in a custom table ?</p>
  
  <p>How should I do it, any help would be greatly appreacited.</p>
  
  <p>I have below code in my action file :</p>
  
  <pre><code>class Post extends \Magento\Framework\App\Action\Action
  
  {
    protected $_objectManager;
  
    public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager) 
    {
      $this-&gt;_objectManager = $objectManager;
  
    }
  
   public function execute()
    {
       $post = $this-&gt;getRequest()-&gt;getPostValue();
       $model = $this-&gt;_objectManager-&gt;create('Chirag\Mygrid\Model\Question');
       $model-&gt;setData('question_title', $post['question_title']);
       $model-&gt;setData('question', $post['question']);
       $model-&gt;save();
  
  
    }
  }
  
  &lt;?php
  /**
   * Copyright © 2015 Magento. All rights reserved.
   * See COPYING.txt for license details.
   */
  namespace Chirag\Mygrid\Model;
  
  class Question extends \Magento\Framework\Model\AbstractModel
  {
      /**
       * Initialize resource model
       *
       * @return void
       */
      protected function _construct()
      {
          $this-&gt;_init('Chirag\Mygrid\Model\Resource\Question');
      }
  }
  
  
  &lt;?php
  /**
   * Copyright © 2015 Magento. All rights reserved.
   * See COPYING.txt for license details.
   */
  namespace Chirag\Mygrid\Model\Resource;
  
  class Question extends \Magento\Framework\Model\Resource\Db\AbstractDb
  {
      /**
       * Initialize resource model
       *
       * @return void
       */
      protected function _construct()
      {
          $this-&gt;_init('questions_and_answers', 'question_id');
      }
  }
  
  
  &lt;?php
  /**
   * Copyright © 2015 Magento. All rights reserved.
   * See COPYING.txt for license details.
   */
  namespace Chirag\Mygrid\Model\Resource\Question;
  
  class Collection extends \Magento\Framework\Model\Resource\Db\Collection\AbstractCollection
  {
      protected function _construct()
      {
          $this-&gt;_init('Chirag\Mygrid\Model\Question', 'Chirag\Mygrid\Model\Resource\Question');
          $this-&gt;_map['fields']['page_id'] = 'main_table.page_id';
      }
  
      /**
       * Prepare page's statuses.
       * Available event cms_page_get_available_statuses to customize statuses.
       *
       * @return array
       */
      public function getAvailableStatuses()
      {
          return [self::STATUS_ENABLED =&gt; __('Enabled'), self::STATUS_DISABLED =&gt; __('Disabled')];
      }
  }
  </code></pre>
  
  <p><strong>1st Edit:</strong></p>
  
  <p>I had successfully completed this and have uploaded the whole setup to Git, please find below URL in case you want to check it out :</p>
  
  <p><a href="https://github.com/chiragit007/Customgrid/" rel="noreferrer">FAQ with custom grid extension in Magento 2</a></p>