Anything added via spacemacs/add-toggle or things available in SPC t and SPC T should be proper toggles. This way, you can toggle them in user-config if you want to change the default state.
Specifically, spacemacs/toggle-transparency (and the related spacemacs/toggle-transparent-frame) both open a micro-state (in addition to toggling the setting). This means, that, if you want to have a transparent frame by default, you cannot just add (spacemacs/toggle-transparency) to your .spacemacs, because it will open the micro-state instead of just toggling transparency.
I’m not sure what other toggles do this, if there are any at all.
Ah, for now, I’m using this code in my user-config as a workaround:
later , spacemas reload config
SPC f e R
if you want load theme
SPC T s and select theme and enter
npm installation not working under Debian Stretch
I just tried to install node and npm on Debian Stretch. I installed node like decribed here.
After installing nodejs-legacy too I got the node command working but npm command still won’t be found.
So, I tried to install it manually via apt-get install npm but it just tells me that it can’t find the package. Next I tried the “Fancy Install (Unix)” from npm repository which fails with…
later I look this a solution I things so … and saw if install nvm and later install with nvm install npm ??? ok I go
open https://github.com/creationix/nvm install NVM Node Version Manager
Install script To install or update nvm, you can use the install script using cURL:
The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc, ~/.profile, or ~/.bashrc).
Note: On Linux, after running the install script, if you get nvm: command not found or see no feedback from your terminal after you type:
later you can run …
This post is the first in a series of blog posts about Ruby for Rails beginners. These are specifically for Rails developers who want to solidify their grasp of the Ruby language.
More than a decade ago, I started learning Rails before I knew any Ruby. Rails is written in Ruby of course, so when writing Rails code you are writing Ruby code. But at the beginning, I didn’t fully understand how Ruby worked. And that’s fine. A lot of people started learning Rails and picked up Ruby along the way.
The “Ruby for Rails” series will help you learn Ruby to make you a better Rails programmer.
In this blog post, we’ll talk about blocks. Ruby blocks can be confusing to beginners but it’s important that you learn them because you’ll keep on using them on your Rails application.
One of the first code you’ll see with blocks is with loops.
The block is inside do and end. This code displays the numbers 1 to 10. When you read it, it kind of makes sense. From 1 to 10, for each i, puts i. If you have experience with other programming languages, you might think this is just a more complicated way to do loops.
each isn’t only for numbers. You can also iterate through an array.
This code iterates through each element and prints the name. In Rails, you commonly use each when iterating through your model.
Say you have a Post model with a title. When you call each on Post.all , you iterate on each of those posts and the value is assigned to **post **which is inside
|| . Since post is a Post object, you can call post.title inside the block.
The examples so far show that blocks can be used to iterate through some objects. But the iteration is a by product of the each method. Blocks aren’t just for iteration. Here’s another common code in Rails.
|We use <%%> because this code appears on ERB templates. form_with is used to display an HTML form. Here, we call the form_with method and passes the Post.new parameter. form_with yields an object which we assign to form. You can use any variable inside||. We could have used f here instead of form.|
In the examples above that used each, we yield each of the objects we’re iterating through. In form_with, we yield exactly one object which is the FormBuilder associated with the model. Inside the block you can use FormBuilder’s methods to generate fields like text_field, text_area, check_box, button, etc.
All the fields inside the block are captured and displayed inside the HTML form element.
These are just a few examples of blocks. You’ll see more when writing Rails code. So don’t get blocked out when coding!
I’d like this… original post by https://www.engineyard.com/blog/ruby-for-rails-blocks
attr_accessor is used to define an attribute for object of Model which is not mapped with any column in database. This answers question - What is attr_accessor in Rails.
1. attr_accessor Methods
attr_accessor creates two methods i.e. getter method and setter method.
**getter method **- it is used to retrieve value of the attribute
setter method - it is used to set value to the attribute
When to use attr_accessor in Rails?
Whenever you want to show certain attribute for particular form but you do not want to store it’s value in the database then you use attr_accessor for that model as follows,
Suppose we have a Model called user in out database with following fields,
And we define attr_accessor :type_of_user as follows,
Now, whenever you create a object of the class User then you can assign a value to it’s attr_accessor.
This will create new object of class User and assign given attribute values. You can assign value to attr_accessor variable as follows,
This assigns ‘middle-aged’ value to the attribute type_of_user attr_accessor.
getter and setter in Action For attribute type_of_user getter and setter methods are created as follows,
And these are used whenever we assign or retrieve values from the attr_accessor.
- Usage in Classes Whenever changing value of the attr_accessor variables, we need to use self.variable_name = to assign new value to the variable. Otherwise, it will consider it as a local variable resulting into incorrect values.
Here, it the above service class we have defined name as the attr_accessor. We need to change it’s value based on some condition. And we return it’s value from process method.
When we execute this class as,
We can see that process method has returned nil.
In the block,
As the if condition is false, and value of name is returned from the process method, name is considered as the local variable. Local variable name does not have any value. Thus, it returns nil.
To correct the above service class, we need to use explicity self when assigning value to the attr_accessor variable as given below,
Now if we execute this class, we will get expected result as given below.
- Lifetime of attr_accessor attr_accessor is accessible throughout object’s lifecycle. When object is saved using any of ActiveRecord method, save, update etc. all attributes of Model other than attr_accessor are saved in the database.
How to Access Throughout lifecycle of object, you can access the value of attribute accessor as follows,
- Conclusion We learned what is attr_accessor in Rails and how to use it with Rails .
Ruby 2.5.0-preview1 Released
We are pleased to announce the release of Ruby 2.5.0-preview1.
Ruby 2.5.0-preview1 is the first preview release toward Ruby 2.5.0. It introduces some new features and performance improvements, for example:
After installing the beta version through rvm …
The 2.5.0-preview1Ruby language version has just been released. Because it is not a stable version, its use is not yet recommended .
** Inverse backtrace**
The backtrace (list of methods that were run before an error happened) will start to be displayed in reverse order. Using the following code as an example:
if the same file is run in ruby 2.4 you get…
Rescue / else / ensure will be allowed inside of / end blocks
Running with Ruby 2.4:
Currently we can only capture exceptions within methods or blocks begin/ end, ie:
: Output Error caught: boom
: Output Error caught: boom.
But the code below doesn’t work:
Running with Ruby 2.5:
In the version that is about to be released, this is possible. The output of the above code will be:
New method yield_self
According to the official documentation Ruby 2.5
- Yields self to the block and returns the result of the block.
Although very similar to the tapclass method Object(which is very useful, by the way), your returns are different.
While with the method tapyou open a block and at the end the object itself is returned, with the yield_self, the result of the block is returned.
save method was called,
object is returned
I could not think of a practical case to use it, but certainly had a reason to have been added :)
The new version will also bring other new features, such as support for Unicode version 10, which includes 56 emojis created this year . You can see a complete list with all the news in this document .
To install Ruby 2.5 (though not yet recommended for not being a stable release) through RVM, simply run:
rvm install 2.5.0-preview1
for more information visit Ruby 2.5.0-preview1 Released
Yes!!! Enjoy Ruby 2.5.0-preview1 Released
subscribe via RSS