I used RubyMine CTRL+ALT+G to generate a Model called User
class CreateUsers < ActiveRecord::Migration[5.2]
def change
create_table :users do |t|
t.timestamps
end
end
end
I try to use autocomplete and it doesnt work.
I remove [5.2]. It works.
class CreateUsers < ActiveRecord::Migration
def change
create_table :users do |t|
t.timestamps
end
end
end
I am using Rails 5.2 and Ruby 2.5.1p57 inside of a RVM installation on RubyMine 2018.2
I have tried invalidating caches.
How do I get autocomplete to work?
Related
When setting a class attribute as a property in Enterprise Architect (Property checkbox in the attribute's window), is there a way to tag the getter as a query (IsQuery checkbox in the method's window advanced tab) by default? It's not done by default and thus I have to do it manually for every property getter.
I don't think there's an option to set for this, but you might try the Template Package.
This special package is used to serve as a template for all new elements, so it might set the isQuery property as well.
If that doesn't work you can make a little script as workaround to set it for every getter.
The property EA.Method.IsQuery is available in the API.
So a VBScript script to update this could be something like
option explicit
!INC Local Scripts.EAConstants-VBScript
'
' Script Name: Set IsQuery Getter
' Author: Geert Bellekens
' Purpose: sets the IsQuery property to true for all operations in the selected package with stereotype "property get"
' Date: 2016-01-22
'
sub main
dim selectedPackage as EA.Package
set selectedPackage = Repository.GetTreeSelectedPackage()
dim element as EA.Element
dim operation as EA.Method
for each element in selectedPackage.Elements
for each operation in element.Methods
if operation.Stereotype = "property get" then
operation.IsQuery = true
operation.Update
end if
next
next
end sub
main
I'm using rails 4 and rspec with capybara for testing.
I want to disable css in my test environment. How can I do that? Can anyone help me.
The simplest way - skip CSS files loading in your /app/views/layouts/application.html.erb for test env.:
<% unless Rails.env.test? %>
<%= stylesheet_link_tag "application", :media => "all" %>
<% end %>
Capybara allows you to blacklist specific URLs from being loaded. You can utilize this feature to block the loading of your CSS files. For example if your CSS is loaded from /assets/application.css:
RSpec.configure do |config|
config.before(:each, js: true) do
page.driver.browser.url_blacklist = [
"http://127.0.0.1:#{page.server.port}/assets/application.css"
]
end
end
You can confirm what assets are getting loaded by turning on Capybara's debugging. To enable debugging simply set the driver to :webkit_debug instead of :webkit
Capybara.javascript_driver = :webkit_debug
I have created few static pages with awesome high_voltage gem.
My pages are static, except a different form in each page.
Forms are supposed to grab user details and send emails (and may be save details in db)
Question:
How should I proceed with this ?
I am concerned more about rails approach,
e.g.
How can I add validation without custom coding (both at client / server side)
How can take help from rails helper method ?
Suppose, I would like to save those fields in db, how should I deal with that ?
In nutshell, I want to use as maximum of rails magic without manually dealing with things.
What I have tried ?
Currently, I have forms in each page. Each form posts at same controller (PagesController) with post method.
I then differentiate them, based on hidden input on respective form.
I do not have any validations for now.
I finally created a model without activerecord, following this great article.
I created a model like below.
class Message
include ActiveModel::Validations
include ActiveModel::Conversion
extend ActiveModel::Naming
attr_accessor :name, :email, :subject, :body
validates :name, :email, :subject, :body, :presence => true
validates :email, :format => { :with => %r{.+#.+\..+} }, :allow_blank => true
def initialize(attributes = {})
attributes.each do |name, value|
send("#{name}=", value)
end
end
def persisted?
false
end
end
I have answered this post in more detail here:
Render partial from static page
Here is the commit to a demo repository to make this work:
https://github.com/harlow/high_voltage_demo/commit/0cdbca5b0fe898d27df22787498fc7e350e81422
I am using rails 3.2.11 and coffee rails 3.2.2.
Here I am trying to render a coffee script in a file /app/views/my_files/create.js.coffee.erb
Here is what my controller code looks like
class MyFilesController < ApplicationController
respond_to :js
def create
end
end
On hitting create action I get missing template error. But when I rename file create.js.coffee.erb to create.js.coffee it works fine.
I am not understanding what is the problem with .erb extension over .coffee, and in this case why it gives missing template error, when template is already there?
Thanks
Rename your file to create.js.coffee
See
How to render new.js.coffee.erb in app/views?
Just had the same problem...
Is there a particular reason you are trying to render coffeescript as a view rather than using it as an asset?
.erb is a ruby script file that produces an html file when compiled.
.js.coffee results in a .js file when compiled. You should be using .erb with a create.html.erb template that in turn uses your create.js.coffee.
<%= javascript_include_tag "create" %>
This should be in your create.html.erb which will be called by the create method in your MyFilesController
i have a very similar question like this one:
Rails redirect_to with params
so, i learned from this thread, that i can add Params to the Controllers redirect_to like this:
format.html { redirect_to #order, :test => "test", notice: 'Order was successfully created.' }
As far as i understood it, with this, i should be able to show the value of :test in the view.
But if i try to access it like this
<p>
<b>Zahlungsart:</b>
<%= params[:test] %>
</p>
nothing happens.
Also it doesn´t seem to be a part of the parameters cause
<%= params.inspect %>
just shows
{"action"=>"show", "controller"=>"orders", "id"=>"32"}
I don´t know what exactly went wrong here.... the redirect_to is the one, which is called by default by the Controller´s "create" action.
So far, i fixed this by just defining $test which is accessible with <%= $test %> in the view... but this seems to be very ugly for me (isn´t it???).
Just to make it clear, the parameter i want to pass to the view is not an instance of a class like the #order in the default definition of the controller is. it´s just a varialbe with a value that i want to pass to the view.
what would be the normal (RESTful <- if i´m understanding this expression in the right way...) way of just adding a param???
Thanks in advance for enlightening me once again ;-)
Greetings
Tobi
You should use it like this
format.html { redirect_to order_path(#order, :test => "test"), notice: 'Order was successfully created.' }